I am trying to port my Web app from Tomcat 5.5 to Tomcat 6.0. I would like to know if one has to use JSF 1.2 or if JSF 1.1 can still be used. I would like to perform the migration in two steps, first by upgrading Tomcat, then migrating to JSF 1.2. But maybe I have to upgrade both at once. I currently get some errors in my JSF 1.1 pages. The first time I use a managed bean in one of the expression value, I get the following error:
According to TLD or attribute directive in tag file, attribute value does not accept any expressions
It sounds like there are still some issues with the EL backwards compatibility in Tomcat 6. A JSF 1.1 based application should be able to run without modification.
OK. Well, I guess I will have to switch to JSF 1.2 right away. No big deal. I would like to run say the sample apps that come with JSF 1.2, but I haven't been successful. Not sure what files should be copied in the Tomcat distribution (like the lib diectory), or if there is anything that needs to be modified after the web app is installed. Has someone come up with a document on how to get JSF 1.2 to work inside Tomcat 6.0? What steps should be taken to get for instance the jsf-guessNumber.war app to work?
I have seen a post that gives some hints (http://forums.java.net/jive/thread.jspa?messageID=168287), but I haven't been able to get things to work even after following these instructions.
I started with a clean installation of tomcat 6.0.2 and put jsf-api.jar and jsf-impl.jar as well as the commons libraries beanutils, collections, digester and logging into my webapps lib folder. I use jsf1_2_03_rc.
I then get this error on deploy:
java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl
I then added the el-ri.jar to my webapp and the webapp is deployed fine, but when I access a page I get a Servlet Exception:
root cause:
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
The tomcat log says:
INFO: JSF1027: [/myApp] The ELResolvers for JSF were not registered with t
he JSP container.
I then added the jstl.jar and standard.jar and got:
org.apache.jasper.JasperException: According to TLD or attribute directive in tag file, attribute value does not accept any expressions
I guess this happens, because the jstl.jar is an old library for JSP2.0 and JSF 1.2 uses the unified EL.
I looked through the libraries in the tomcat lib folder and saw that there is another implementation of the ExpressionFactoryImpl in the jasper-el.jar and in another jar there is also the ELResolver. Can I configure JSF to use these tomcat classes instead of com.sun.el.* ? From my understanding I should not have to add any libraries for JSP and EL, because they are now part of Java EE and should be implemented by the tomcat. But JSF seems to ignore those and ask for different libraries.
The commons libraries beanutils, collections, digester and logging used to be distributed with JSF. I can't find them anymore. I am wondering where I can get them.
I spent more time getting a simple JSF 1.2 app to work. Probably, the problems I am experimenting are related to not having the right librairies installed or not in the right location.
I was copying over libraries like jstl.jar and standard.jar in my webapp WEB-INF/lib directory, but I guess this is not compatible with JSF 1.2. But there are still errors even after I remove these files. Here are excerpts from the exception stack:
WARNING: JSF1004: Cannot instantiate component of type {0}
javax.faces.FacesException: Cant instantiate class: com.sun.javaee.blueprints.components.ui.components.GraphComponent.
...
INFO: validateJarFile(/usr/apache-tomcat-6.0.2/webapps/hello/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
...
Nov 24, 2006 4:11:23 PM com.sun.faces.config.ConfigureListener registerELResolverAndListenerWithJsp
SEVERE: Error Instantiating ExpressionFactory
java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1355)
This clears the java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl
error and startup seems to be happening without error. But as soon as the user accesses the application, an exception is raised:
Nov 24, 2006 7:46:07 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:150)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:215)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:818)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:624)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:595)
Thanks martin, that was exactly what I was looking for. Is that specific to the ExpressionFactory or can you configure the use of any class this way?
I'll give it another try when I have time. Unfortunately we decided to develop in JSF 1.1 again until there is a stable environment using jsf1.2 and tomcat.
1. Using the JSF 1.2 [1], copy the jsf-api.jar and jsf-impl.jar to
TOMCAT_HOME/lib (just to make it easy). No need to install any
commons libraries, as the necessary dependencies are bundled
in jsf-impl.jar (under the namespace com.sun.org.apache....).
2. downloaded JSTL 1.2 [2] and install it in TOMCAT_HOME/lib
as well.
3. start tomcat
4. deploy jsf-guessNumber
Use the above, guessNumber worked like a charm without
having to add any parameters in order to get JSF to work.
[1] https://javaserverfaces.dev.java.net (1.2_02 or the latest RC should be fine)
My issue boiled down to the version of jstl installed in my Tomcat lib directory. I was not aware I should use version 1.2 and didn't know where to get it.
In case anyone cares here's my update for Tomcat 6.0.7 and JSF 1.2_03. I got guessNumber working, I had to install jsf-api.jar, jsf-impl.jar, and jstl-1.2.jar as per above post.
I also had use the apache expression factory.
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.apache.el.ExpressionFactoryImpl</param-value>
</context-param>
All the libs were placed in tomcat/lib and the context param was added to tomcat/conf/web.xml. I haven't tried it in the war yet, but all seems good so far.
Just to confirm - you're working fine without the
ELFactory context init parameter, correct?
I'm not Martin, but no, I've found that I must have the context init parameter.
I have a simple login application that works without the parameter, but if I add a length validator to an input field, I get an exception. After hunting down this thread, I found that adding the context init parameter let me use the length validator without any exceptions.
This problem really should be fixed soon. I don't know if it's Tomcat's fault or the RI's fault, but either way it's not good publicity for JSF 1.2. Nobody should have to add an obscure context init param that's not even documented in the 1.2 spec just to get something as simple as a length validator to work.
This topic has
18
replies
on
2
pages.
1
|
2
|
Next »