java.lang.ClassNotFoundException: javax.faces.application.ApplicationFactory
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7963764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.ClassNotFoundException: javax.faces.application.ApplicationFactory
提问by Buhake Sindi
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:
我正在使用 JSF 2 编写一个 Web 应用程序。我已经下载了 mojarra-2.1.3-FCS-binary.zip 和 myfaces-core-assembly-2.1.3-bin.zip,对于每个库,我得到以下内容例外:
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##代码##0(URLClassLoader.java:58)
at java.net.URLClassLoader.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.access0(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.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext.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.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.
对于 Mojarra,我包含javax.faces.jar
在WEB-INF/lib
文件夹中,对于 MyFaces,我将 jar 替换为以下内容: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.
我已经包含了 jstl-api-1.2.jar 和 jstl-impl-1.2.jar。
And ApplicationFactory
is found in those jars. What is the issue with JSF in these instances?
并且ApplicationFactory
是在那些罐子里找到的。在这些情况下,JSF 有什么问题?
I'm using Tomcat 7 to run my web application.
我正在使用 Tomcat 7 来运行我的 Web 应用程序。
回答by BalusC
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
.
此异常表明 Mojarra API 是从服务器专用的类加载器加载的,而 Mojarra/MyFaces impl 是从 webapp 专用的类加载器加载的。从取出钻嘴鱼科的JAR Tomcat/lib
,JRE/lib
,JRE/lib/ext
和/或Tomcat共同lib和最终所有的地方比其他Web应用程序的运行时类路径/WEB-INF/lib
。