java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener when using MyFaces with WASCE/Geronimo

时光毁灭记忆、已成空白 提交于 2019-11-27 20:35:00
Caused by: java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener

The missing class is part of Mojarra, which is actually the competitor of MyFaces.

You shouldn't need that class at all when using MyFaces. This exception can have the following possible causes:

  • There's a manually definied <listener> entry in webapp's web.xml or the web-fragment.xml of any of the deployed JARs in /WEB-INF/lib which references this Mojarra-specific listener class.

  • There's somewhere a loose Mojarra .tld file in the classpath (very unlikely, who would ever extract a JAR file and put its loose contents in the classpath?). TLD files get autoinitialized and can contain a <listener> entry which can trigger autoregistration of a ServletContextListener implementation (such as the Mojarra ConfigureListener).

Those conflicts can be fixed by just removing it.

I deployed an web application with Myfaces in a Jetty server and it was necessary to use a listener and an additional init parameter to use facelets:

<context-param>
    <param-name>org.apache.myfaces.FACES_INITIALIZER </param-name>
    <param-value>org.apache.myfaces.webapp.FaceletsInitilializer</param-value>
</context-param>
<listener>
     <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

I was using mojarra implementation for compilation and was relying on apache tomcat for runtime. But tomcat uses myfaces implementation. So had to include mojarra impl jar in the WEB-INF/lib to resolve the issue

I was with the same problem. When I tried to run a .html file with Eclipse using Tomcat7 as the local server I received the 404 error on the Browser. And in Eclipse's console was showing the error "ClassNotFoundException: com.sun.faces.config.ConfigureListener".

The problem was the Mojarra library (.jar) I was using in my Dynamic Web project. I was using the javax.faces-2.3.0-m04.jar.

-> Solution:

Download an older version on Mojarra's repositories https://maven.java.net/content/repositories/releases/org/glassfish/javax.faces/ . In my case, I downloaded the 2.2.7 version (javax.faces-2.2.7.jar).

Then I created a new Dynamic Web project in Eclipse using JSF v2.0 and assigned with the javax.faces-2.2.7.jar file in the library section.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!