Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
701 views
in Technique[技术] by (71.8m points)

jsf - java.lang.ClassNotFoundException : com.sun.faces.config.ConfigureListener

We are three people developing a JSF project and we've not been into JSF before. Oddly, with the same data checked out from SVN, one of the team members gets an 404 error everytime using Tomcat 7.0.27.

At the time when Tomcat (used inside Eclipse) starts up, the following log is written out:

01.06.2012 11:45:16 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: ......
01.06.2012 11:45:16 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SnapManCloud' did not find a matching property.
01.06.2012 11:45:16 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
01.06.2012 11:45:16 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
01.06.2012 11:45:16 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 677 ms
01.06.2012 11:45:16 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
01.06.2012 11:45:16 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
01.06.2012 11:45:17 org.apache.catalina.core.StandardContext listenerStart
FATAL: Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4638)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
01.06.2012 11:45:17 org.apache.catalina.core.StandardContext listenerStart
FATAL: Skipped installing application listeners due to previous error(s)
01.06.2012 11:45:17 org.apache.catalina.core.StandardContext startInternal
FATAL: Error listenerStart
01.06.2012 11:45:17 org.apache.catalina.core.StandardContext startInternal
FATAL: Context [/SnapManCloud] startup failed due to previous errors
01.06.2012 11:45:17 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
01.06.2012 11:45:17 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
01.06.2012 11:45:17 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1279 ms

We are using Mojarra 2.0.3 as JSF-Implementation which has been included by Eclipse into the project (and presumably into the classpath).

Indeed there is a entry for com.sun.faces.config.ConfigureListener in web.xml

<listener>
     <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

Does anyone have any starting point where to look for the error? Also, if additional information is required, please let me know.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

JSF is usually bundled in full fledged Java EE application servers such as GlassFish, JBoss AS/EAP, WildFly, WebSphere, WebLogic, etc. However, Tomcat is a barebones JSP/Servlet container which bundles only the JSP and Servlet APIs, no JSF API.

If you want to use JSF on Tomcat, then you'd need to bundle the JSF libraries along with the webapp in its /WEB-INF/lib folder, or to install JSF in Tomcat by placing the JSF libraries in its /lib folder. Apparently that application is designed for real Java EE applications servers and hence doesn't bundle the JSF libraries in /WEB-INF/lib.

There are two JSF implementations available, Mojarra and MyFaces. The com.sun.faces package indicates Mojarra, so download that one and put it in webapp's runtime classpath (i.e. either in webapp's /WEB-INF/lib or in Tomcat's /lib).


Another possible cause is that you deployed the project to a Java EE application server which uses MyFaces instead of Mojarra, while the project was apparently initially developed for Mojarra. That listener is namely Mojarra specific. In such case, you'd better remove the entire <listener> entry from web.xml.

In any case, the explicit registration of Mojarra's ConfigureListener in web.xml is actually only necessary to workaround old buggy servers such as GlassFish v3 and Jetty who failed to find the listener in Mojarra's TLD file. When deployed to a decent server, the whole <listener> entry is unnecessary.

See also:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...