Ich benutze das:
beim Versuch, meine Anwendung auszuführen, erhielt ich die folgende Ausnahme:
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)
Irgendwelche Ideen warum?
Vielen Dank,
Dies kann passieren, wenn der Laufzeitklassenpfad Ihrer Webapp mit mehreren JSF-Impls Versionen verschmutzt wird. Die org.Apache.myfaces
-Einträge in der Stack-Ablaufverfolgung zeigen an, dass Sie MyFaces verwenden. Dieses Problem legt daher nahe, dass Sie eine andere JSF-Implementierung wie Mojarra im Laufzeitklassenpfad der webapp verwenden, die mit ihr in Konflikt steht. Es ist erkennbar an jsf-api.jar
oder jsf-impl.jar
oder javax.faces.jar
. Wenn Sie alle entfernen, sollte dieses Problem verschwinden.
Oder, wenn Sie tatsächlich beabsichtigten, Mojarra anstelle von MyFaces zu verwenden (Sie haben nämlich die beabsichtigte JSF-Impl/-Version an keiner Stelle in Ihrer Frage explizit angegeben, aber Sie haben die JSF-Spezifikation generell wie in "JSF 2.0" angegeben), so dass Sie dies tatsächlich getan haben Keine Ahnung, was Sie alles gemacht haben), dann sollten Sie myfaces-*.jar
-Dateien aus Ihrer Webapp entfernen.
Ergänzend zur Antwort von BalusC habe ich kürzlich diesen Fehler erhalten, als ich versuchte, eine unabhängige JAR mit einer Spring Boot-Anwendung auszuführen, die JSF als Front-End mit von Spring verwalteten Beans hat. Das Wechseln der Verpackung von JAR zu WAR hat das Problem gelöst.
Für mich {Tomcat 8, JSF 2.2, JRE 8} haben die folgenden Schritte funktioniert:
Laden Sie die JSTL-Jars-API && IMPL herunter und platzieren Sie sie in Ihrer Tomcat-Bibliothek.
Seit dem Herunterladen von Majorra direkt aus Eclipse in Projekt Facetten ist die Konfiguration in letzter Zeit nicht möglich; "Zip-Datei ist leer Ausnahme", Laden Sie die Dateien jsf-api.jar und jsf-impl.jar manuell herunter, und fügen Sie sie in eine Benutzerbibliothek ein.
Das ist meine web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>TestJSF</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.Sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>