I'm using this :
- 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)
Any ideas why?
Thanks,
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 byjsf-api.jar
, orjsf-impl.jar
, orjavax.faces.jar
. If you remove all of them, then this problem should disappear.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.See also:
Complementing BalusC's answer, I recently got this error when trying to run an independent JAR with a Spring Boot application that has JSF as front-end with Spring-managed beans. Switching the packaging from JAR to WAR solved the problem.
For me {Tomcat 8, JSF 2.2, JRE 8}, the following steps worked:
Download JSTL jars API && IMPL and place it in your Tomcat lib.
Since downloading Majorra directly from eclipse in project facets configuration is recently impossible ; "Zip File is empty Exception", manually download jsf-api.jar and jsf-impl.jar and include them in a new user library added to build path(only once!).
This is my web.xml: