jsf – java.lang.IllegalStateException:找不到工厂javax.faces.context.FacesContextFactory的备份

前端之家收集整理的这篇文章主要介绍了jsf – java.lang.IllegalStateException:找不到工厂javax.faces.context.FacesContextFactory的备份前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我创建了我的hello world JSF项目,但是当我部署到Tomcat 7时,我得到这个例外:
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添加到我的项目中:

> jstl-1.2.jar
> javax.faces-api-2.2.jar

这是怎么造成的,我该如何解决呢?

解决方法

异常基本上告诉它找不到JSF实现.

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是不对的.有两个问题:

>这是“蓝图”API JAR,意图用于JSF实现者,如MojarraMyFaces.
>你忘记了JSF实现JAR.

如果您想使用Mojarra,则可以按照download page的说明安装Mojarra的方法有两种:

>一个JAR:javax.faces-2.x.x.jar
>或者两个JAR:jsf-api-2.x.x.jarjsf-impl-2.x.x.jar,其中版本号必须完全匹配.

摆脱那个javax.faces-api-2.2.jar并将正确的JAR放在/ WEB-INF / lib中,这个异常应该消失.到目前为止,Mojarra 2.2.8是最新版本,一个JAR比两个松散的JAR更干净,所以去下载javax-faces-2.2.8.jar来替换错误的JAR.

原文链接:https://www.f2er.com/java/124083.html

猜你在找的Java相关文章