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
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
andjavax.faces-api-2.2.jar
The javax.faces-api-2.2.jar
alone is not right. There are 2 problems:
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.
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.
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: