This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Upgrade from JSF1.2 to JSF2  RSS feed

 
Aj Jaro
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confident there is something simple I'm missing here. I'm planning the upgrade from JSF1.2 to JSF2 using Tomcat7 and I continue getting this error trying to render a basic hello.xhtml page. What am I missing to cause this exception?

I have added these JAR files to my Tomcat lib directory:
- el-api-2.2.jar
- el-impl-2.2.jar
- javaee-api-7.0.jar
- javax.faces-2.2.0.jar
- javax.el-api-2.2.1.jar
- javax.servlet.jsp-api-2.2.1.jar
- javax.servlet-api-3.0.1.jar
- jsp-api-2.1.jar
- jstl-api-1.2.jar
- servlet-api-2.5.jar

I've removed these from my Tomcat lib directory:
- el-api.jar
- jsp-api.jar
- servlet-api.jar




hello.xhtml


web.xml (snippet)


faces-config.xml (snippet)
 
Tim Holloway
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your mistake was in removing those jars from the TOMCAT_HOME/libs directory and putting them in your WAR. Put them back where they belong!

JSF is an integral part of JEE, so in a full-stack JSF2 server's application, you not only would not have those jars in your WAR, you wouldn't have the JSF-impl JAR in your WAR, either, but that one isn't part of Tomcat.
 
Aj Jaro
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't the replacement JARs (el-api-2.2.jar, jsp-api-2.1.jar, and servlet-api.jar) be suitable replacements for the ones I removed? The ones I removed are older versions and shouldn't the new ones have all the same capabilities along with JSF2?
 
Tim Holloway
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't matter. Those jars were in TOMCAT_HOME/lib because they belong to TOMCAT, not to the web application. They are used by ALL webapps, not just one, You've seriously damaged your Tomcat server.

Also, you cannot mix and match versions on stuff like that. Those API jars define the particular version of the J2EE spec that that particular version of Tomcat supports - meaning that that's what Tomcat's internal logic supports. You cannot upgrade or downgrade those jars and expect Tomcat to function properly. If at all.
 
Aj Jaro
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim for helping point me in the right direction. Unfortunately, even with the standard Tomcat 7 installation the same exception is still thrown. Do you have any further suggestions?

 
Tim Holloway
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, NullPointerExceptions in the View construction process are extremely hard to diagnose. Generally they come from improper initialization of backing data models, especially SelectOneListbox and its relatives.

You might also want to check to make sure that the Backing bean has View or Session scope, as Request scope can cause this problem in some cases.
 
Aj Jaro
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just thinking about this today. Is it possible or likely that this is caused by running with RichFaces 3.3.3 even though I'm not referencing it within hello.xhtml? Specifically, is it a conflict between Facelets 2 and RichFaces 3.3.3?
 
Tim Holloway
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. RichFaces 3 works with JSF2, although in Tomcat it doesn't get full tag support (for example, the "f:ajax" tag). The NUllPointerException is almost certainly a bug in the application code, unless you've still got libraries in the wrong places.

But RichFaces 3 doesn't support IE9, IE10, IE11 or anything newer and never will, according to JBoss/Red Hat. It will malfunction unless you tell the user's browser to operate like it's IE8. There's a crucial JavaScript function that Microsoft implements in IE in a way that conflicts with a function expected in RichFaces 3.

As long as you are upgrading, you should upgrde to RichFaces 4. Microsoft has already announced that their IE8 support is going to end in 1st Quarter 2016. After that, they aren't going to be making any attempt to keep compatibility.

 
Aj Jaro
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thanks Tim. I can only figure it's still a library problem then because the application code for hello.xhtml is quite simple. If you have any further ideas on which libraries I've incorrectly placed or am missing that would be greatly appreciated.

We intend on doing a phased upgrade approach to RichFaces 4. In this first phase, we're just going to make sure that our application is working with JSF2. Then in the second phase we'll upgrade RichFaces. In this way, we'll try to reduce the risk/impact of each change by making smaller changes.

hello.xhtml
 
Tim Holloway
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing appears obviously wrong with the sample xhtml you just listed.

So if it's not working, I'd suspect that your copy of Tomcat is damaged. Try removing and re-installing Tomcat. Do not modify anything in the Tomcat lib directory.

Then, check the following things in your example WAR:

1. Make sure that none of the libraries in the WEB-INF/lib directory duplicates any version of the libraries in the Tomcat lib directory.

2. Examine the web.xml file carefully to ensure that you have the proper configuration set for Facelets. Important Note There are significant differences between Facelets configurations between RichFaces 3 and RichFaces 4. Make sure you reference the proper documentation. Also make sure that you're using Tomcat configuration information, since Tomcat doesn't have JSF built-in like the full-stack JEE servers do.

3. It's a good idea to set up a minimal app with only that one test page in it. That way, other app components won't be present to possibly interfere with its proper operation.
 
Aj Jaro
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim, thanks again for all your help.

I was able to get the hello.xhtml working properly and my configuration is below. Tomcat didn't need to be reinstalled as changing the libraries didn't impact the overall installation, but I did put the original libraries back in place.

The version in faces-config.xml seems like there are some major changes between 1.2 and 2.0.


Libraries added to webapp:
javax.faces-2.2.0.jar
jsf-facelets-1.1.15.B1.jar
jstl-1.2.jar
richfaces-impl-jsf2-3.3.3.jar

hello.xhtml


web.xml (snippet)


faces-config.xml (snippet)
 
Tim Holloway
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One reason for starting with a clean Tomcat is that in addition to getting you back to a known-good set of libraries, it also ensures that there's no lint left lurking around in obscure corners.

Where did you get your JSF2.2 jar? I just checked one of my projects, and I don't have a unified jar, I have jsf-api-2.0.2-FCS.jar and jsf-impl-2.0.2-FCS.jar. It's an old project, though. Still, I'd expect the 2 jars to be distinct, since I think that the api jar is needed by full-stack servers such as JBoss/Wildfly, but the impl jar is inside JBoss itself.

In theory, there shouldn't be a need for a separate Facelets jar for JSF2, but thats where RichFaces 3 muddies things. I think it's hung up on the old version of Facelets. I know it does require some facelets settings in web.xml that RichFaces 4 does not.
 
Aj Jaro
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, they changed the JAR file construction around a bit under the Mojarra Issue 2028 so that it was contained within one JAR instead of multiple ones.

Thanks again so much for your help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!