java.lang.IllegalStateException:找不到工厂 javax.faces.context.FacesContextFactory 的备份 [英] java.lang.IllegalStateException : Could not find backup for factory javax.faces.context.FacesContextFactory
问题描述
我创建了我的 hello world JSF 项目,但是当我部署到 Tomcat 7 时,出现此异常:
I created my hello world JSF project, but when I deploy to Tomcat 7, I get this exception:
java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory.
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1135)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:379)
at javax.faces.webapp.FacesServlet.init(FacesServlet.java:350)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:864)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
我已将这些 JAR 添加到我的项目中:
I have added those JARs to my project:
jstl-1.2.jar
javax.faces-api-2.2.jar
这是怎么引起的,我该如何解决?
How is this caused and how can I solve it?
推荐答案
IllegalStateException: 找不到工厂 javax.faces.context.FacesContextFactory 的备份
IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory
如果将备份"替换为备份",则此异常更容易理解.通过实施".它最终归结为我找到了 JSF API,但在与我找到 JSF API 的位置相同的类路径上下文中没有任何 JSF 实现".换句话说,您在运行时类路径中的某处有一个 JSF API,它没有附带任何 JSF 实现.例如.有一个 jsf-api.jar
甚至 javaee.jar
没有任何 jsf-impl.jar
或 javax.faces.jar
在同一类路径上下文中.请注意,Web 应用程序可以有多个类路径上下文.根据类加载规则,JSF impl 必须与第一次遇到的 JSF API 出现在完全相同的位置,并且您需要绝对确保没有重复和/或冲突的版本.
This exception is easier to understand if you replace "backup" by "implementation". It ultimately boils down to "I found the JSF API, but nowhere a JSF impl in the same classpath context as where I found the JSF API". In other words, you've a JSF API somewhere in runtime classpath which isn't accompanied with any JSF impl. E.g. having a jsf-api.jar
or even javaee.jar
without any jsf-impl.jar
or javax.faces.jar
in the same classpath context. Note that a web application can have multiple classpath contexts. The JSF impl has to be present in exactly the same location as the first encountered JSF API according to the classloading rules, and you need to make absolutely sure that there are no duplicate and/or conflicting versions.
在您的具体情况下,
我已经将这个 jars 添加到我的项目中:jstl-1.2.jar
和 javax.faces-api-2.2.jar
>
单独使用 javax.faces-api-2.2.jar
是不对的.有两个问题:
The javax.faces-api-2.2.jar
alone is not right. There are 2 problems:
如果您想使用 Mojarra,请按照其 自述.在您的特定情况下,摆脱那个 javax.faces-api-2.2.jar
并放置最新的 javax.faces-2.xxjar
在 /WEB-INF/lib
或 中>pom.xml
并且这个异常应该消失.
Provided that you'd like to use Mojarra, follow the installation instructions in its README. In your specific case, get rid of that javax.faces-api-2.2.jar
and put the latest javax.faces-2.x.x.jar
in /WEB-INF/lib
or pom.xml
and this exception should disappear.
这篇关于java.lang.IllegalStateException:找不到工厂 javax.faces.context.FacesContextFactory 的备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!