java.lang.NoClassDefFoundError: javax/faces/FacesException [duplicate]
Asked Answered
G

4

9

I'm trying to deploy a web application which I have imported from Eclipse workspace to NetBeans. But it's not getting deployed, instead it's giving me the below exception.

15 Jul, 2011 5:59:04 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.apache.myfaces.component.html.util.StreamingDestroyerListener
java.lang.NoClassDefFoundError: javax/faces/FacesException
        at org.apache.myfaces.shared_tomahawk.config.MyfacesConfig.<clinit>(MyfacesConfig.java:80)
        at org.apache.myfaces.component.html.util.StreamingDestroyerListener.contextInitialized(StreamingDestroyerListener.java:32)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:521)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1359)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        **at java.lang.reflect.Method.invoke(Method.java:597)**
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
        **at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)**
        at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
        at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:849)
        at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:351)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:199)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:558)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
        **at java.lang.Thread.run(Thread.java:619)**

Am I missing some JARs?

Ganda answered 15/7, 2011 at 0:43 Comment(0)
S
12

The NoClassDefFoundError means that the class was present in the classpath during compiletime. Tomahawk has somewhere an import javax.faces.FacesException; line in the codebase. That is one of the classes of the core JSF API.

This means that the JSF libraries are missing in the webapp's classpath. The project was in Netbeans apparently associated with a server which is already bundled with JSF such as Glassfish, JBoss AS, etc. The project in Eclipse is seemingly not properly associated with the server, or the server in question does not have JSF bundled such as Tomcat, Jetty, etc.

The stacktrace hints that you're using Tomcat. You need to download JSF separately and drop the JAR files in webapp's /WEB-INF/lib (there where your Tomahawk libraries also are).

Sinful answered 15/7, 2011 at 20:43 Comment(3)
What, if I'm getting the same error in Jetty (while executing mvn jetty:run) ? I tried to put JSF jar into WEB-INF/lib, but it didn't help.Nolasco
@Dmitri: Maven requires a different way of managing dependencies (heck, it is a way of managing dependencies). You'd need to configure it by pom.xml.Sinful
I know and I added the respective dependency into Jetty config section. The ClassNotFoundError has gone, but now I'm getting java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/component/html/HtmlOutcomeTargetButton.Nolasco
D
3

Yes, CNF exception always means missing JARs. The class loader can't find this:

javax.faces.FacesException

You find it by cutting & pasting the class name into findjar.com, like this:

http://www.findjar.com/index.x?query=javax.faces.FacesException

Due answered 15/7, 2011 at 0:55 Comment(0)
R
0

To add a different experience: when I encountered this problem it was because I was using ICEFaces and had included the ICEFaces jars in Tomcat's $CATALINA_BASE/lib directory, but included javax.faces.jar in my webapp's /WEB-INF/lib directory. The solution for me was to move javax.faces.jar from /WEB-INF/lib to $CATALINA_BASE/lib. Also, make sure you use the correct version of javax.faces.jar if you use something like ICEFaces.

Reamonn answered 14/4, 2014 at 20:5 Comment(0)
P
0

I addressed this issue by removing provided scope from POM on jsf-api and jsf-impl, so Maven can now generate the both jars to Catalina starts up.

Psephology answered 14/2 at 21:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.