5

I am writing a web application using JSF 2. I have downloaded mojarra-2.1.3-FCS-binary.zip and myfaces-core-assembly-2.1.3-bin.zip, and with each library, I'm getting the following exception:

java.lang.NoClassDefFoundError: javax/faces/application/ApplicationFactory
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1663)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:591)
    at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:482)
    at javax.faces.FactoryFinder.access$400(FactoryFinder.java:138)
    at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:959)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:316)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:303)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:219)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:360)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    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)
Caused by: java.lang.ClassNotFoundException: javax.faces.application.ApplicationFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 34 more

For Mojarra, I included javax.faces.jar in WEB-INF/lib folder, and for MyFaces, I replace the jar with the following: myfaces-api-2.1.3.jar, myfaces-bundle-2.1.3.jar, myfaces-impl-2.1.3.jar.

I've included jstl-api-1.2.jar as well as jstl-impl-1.2.jar.

And ApplicationFactory is found in those jars. What is the issue with JSF in these instances?

I'm using Tomcat 7 to run my web application.

2
  • Have you tried to locate the Libaries under "/apache-tomcat-7/lib" ? Commented Nov 1, 2011 at 9:11
  • @Mhh Lecker, the jars mentioned in the question contains the classes. It doesn't "register" when you run the application though. Commented Nov 1, 2011 at 9:14

1 Answer 1

3

This exception suggests that the Mojarra API was been loaded from the server-dedicated classloader while the Mojarra/MyFaces impl is loaded from the webapp-dedicated classloader. Remove the Mojarra JARs from Tomcat/lib, JRE/lib, JRE/lib/ext and/or Tomcat common lib and eventually all places in webapp's runtime classpath other than /WEB-INF/lib.

Sign up to request clarification or add additional context in comments.

6 Comments

I double checked and the javax.faces.jar is only found in my WEB-INF folder. I'm running Tomcat 7.0.20.
jsf-api.jar? javaee.jar? Come to think about it, do you have any JSF specific/related <listener> in web.xml? What Servlet version is your web.xml root declaration set to?
Does jboss-seam.jar have anything to do with the conflict?
jsf-api.jar, javaee.jar is not found in any "system" lib folders and Serlvet version is 3.0. and I don't have any listener specified yet.
Found it. It seems that jboss-seam.jar creates a conflict with my application. Thanks BalusC.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.