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

前端 未结 3 1437
攒了一身酷
攒了一身酷 2020-12-03 17:29

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         


        
相关标签:
3条回答
  • 2020-12-03 17:56

    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:

    • How to properly install and configure JSF libraries via Maven?
    0 讨论(0)
  • 2020-12-03 17:58

    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.

    0 讨论(0)
  • 2020-12-03 18:23

    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
    0 讨论(0)
提交回复
热议问题