java.lang.IllegalStateException:找不到工厂javax.faces.context.FacesContextFactory的备份 [英] java.lang.IllegalStateException : Could not find backup for factory javax.faces.context.FacesContextFactory

查看:197
本文介绍了java.lang.IllegalStateException:找不到工厂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
  • 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 impl.例如.在同一类路径上下文中具有jsf-api.jar甚至javaee.jar而没有任何jsf-impl.jarjavax.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.

在您的特定情况下,

我已将此罐子添加到我的项目中:jstl-1.2.jarjavax.faces-api-2.2.jar

I had added this jars to my project : jstl-1.2.jar and 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:

  • 这是蓝图" API JAR,旨在供JSF实现者使用,例如 Mojarra 如果您要使用Mojarra,请按照其自述文件.在您的特定情况下,请删除该javax.faces-api-2.2.jar并放入最新的> /WEB-INF/libpom.xml中的c10> ,该异常应消失.

    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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆