ApplicationFactory的备份

ApplicationFactory的备份

本文介绍了java.lang.IllegalStateException:找不到工厂javax.faces.application.ApplicationFactory的备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用它:

  • Tomcat 7.0
  • JSF 2.0
  • JRE 7

但是尝试运行我的应用程序时,出现以下异常:

but when trying to run my application, I got the following exception:

java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory.
    at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1011)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:343)
    at org.apache.myfaces.context.servlet.FacesContextImplBase.getApplication(FacesContextImplBase.java:159)
    at org.apache.myfaces.context.servlet.FacesContextImplBase.getELContext(FacesContextImplBase.java:210)
    at javax.faces.component.UIViewRoot.setLocale(UIViewRoot.java:1463)
    at org.apache.myfaces.webapp.AbstractFacesInitializer._createFacesContext(AbstractFacesInitializer.java:477)
    at org.apache.myfaces.webapp.AbstractFacesInitializer.initStartupFacesContext(AbstractFacesInitializer.java:449)
    at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:113)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

任何想法为何?

谢谢

推荐答案

如果您的Web应用程序的运行时类路径被多个JSF impls/版本污染,则可能会发生这种情况.堆栈跟踪中的org.apache.myfaces条目表明您正在使用MyFaces.因此,此问题表明您在Web应用程序的运行时类路径中有另一个JSF实现(例如Mojarra),该实现与之冲突.它可以通过jsf-api.jarjsf-impl.jarjavax.faces.jar识别.如果将它们全部删除,则此问题应消失.

That may happen if your webapp's runtime classpath is polluted with multiple JSF impls/versions. The org.apache.myfaces entries in the stack trace tells that you're using MyFaces. This problem thus suggests that you've another JSF implementation like Mojarra in the webapp's runtime classpath which is conflicting with it. It's recognizable by jsf-api.jar, or jsf-impl.jar, or javax.faces.jar. If you remove all of them, then this problem should disappear.

或者,如果您实际上打算使用Mojarra而不是MyFaces(即您没有在问题的任何地方明确声明意图的JSF实施/版本,但是您只是像在"JSF 2.0"中那样一般性地陈述了JSF规范,所以也许您实际上不知道自己在做什么),那么应该从Web应用程序中删除myfaces-*.jar文件.

Or, if you actually intented to use Mojarra instead of MyFaces (you did namely not explicitly state the intented JSF impl/version anywhere in your question, but you just generically stated the JSF spec as in "JSF 2.0", so perhaps you actually had no clue what you was all doing), then you should be removing myfaces-*.jar files from your webapp.

  • JSF wiki page - Installing JSF
  • How to properly install and configure JSF libraries via Maven?
  • Difference between Mojarra and MyFaces
  • JSF implementations and component libraries

这篇关于java.lang.IllegalStateException:找不到工厂javax.faces.application.ApplicationFactory的备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 04:30