Abdessamad BOUTGAYOUT
Abdessamad BOUTGAYOUT

Reputation: 359

java.lang.IllegalStateException : Could not find backup for factory javax.faces.context.FacesContextFactory

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)

I have added those JARs to my project:

How is this caused and how can I solve it?

Upvotes: 15

Views: 32482

Answers (3)

BalusC
BalusC

Reputation: 1108537

IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory

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.

In your specific case,

I had added this jars to my project : jstl-1.2.jar and javax.faces-api-2.2.jar

The javax.faces-api-2.2.jar alone is not right. There are 2 problems:

  • That's the "blueprint" API JAR, intented for JSF implementors such as Mojarra and MyFaces.
  • You forgot the JSF implementation JAR.

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.

See also:

Upvotes: 26

kayhan yüksel
kayhan yüksel

Reputation: 378

Thanks to My colleuge , @Lookub at stackoverflow ,he added another apache server and the set the port as 8084 , it all compiled. As ide, we are using netbeans 8.2.You may do this at Services>>Servers menu . Hope this helps.

Upvotes: 0

Ravi Kumar Sharma
Ravi Kumar Sharma

Reputation: 1

Need to changed the weblogic-application.xml of the ear project to

<?xml version='1.0' encoding='UTF-8'?>
<weblogic-application xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-application 
    http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd">

    <prefer-application-packages>
        <package-name>org.opensaml.*</package-name>
        <package-name>org.slf4j.*</package-name>
        <package-name>antlr.*</package-name>        
    </prefer-application-packages>
    <prefer-application-resources>
        <resource-name>javax.faces.*</resource-name>
        <resource-name>com.sun.faces.*</resource-name>
        <resource-name>com.bea.faces.*</resource-name>
        <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
        <resource-name>META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider</resource-name>
    </prefer-application-resources>
</weblogic-application>

Follwoing jar version numbers must match exactly:

  • javax.faces-2.x.x.jar
  • jsf-api-2.x.x.jar
  • jsf-impl-2.x.x.jar

Upvotes: 0

Related Questions