Question

The problem is could not find Factory: javax.faces.context.FacesContextFactory, but on Websphere application server.

I have a web application which I ship with my own jsf impl, Mojarra 2.1.24, and expression language 2, but to do this I followed IBM guideline Configuring JavaServer Faces implementation. As stated by IBM I created a shared folder where I put the following jar (which I removed from WEB-INF/lib):

  • el-api.jar
  • el-impl.jar
  • jsf-api.jar
  • jsf-impl.jar
  • jstl.jar

Then I deployed the webapp and linked the shared lib to the webapp.

The web.xml is the following:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0">                
    <context-param>
        <param-name>com.sun.faces.enableMissingResourceLibraryDetection</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>org.ajax4jsf.handleViewExpiredOnClient</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.richfaces.CONTROL_SKINNING</param-name>
        <param-value>enable</param-value>
    </context-param>
    <context-param>
        <param-name>org.richfaces.skin</param-name>
        <param-value>#{applicationBean.skin}</param-value>
    </context-param>

    <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>
        <url-pattern>*.jsf</url-pattern>
        <url-pattern>*.faces</url-pattern>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>   
    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>   
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/org.richfaces.resources/*</url-pattern>
    </servlet-mapping>     
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <mime-mapping>
        <extension>ecss</extension>
        <mime-type>text/css</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>xhtml</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

The application start produces the following exception:

Caused by: java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory. 
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1010)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:342)
at javax.faces.webapp.FacesServlet.init(FacesServlet.java:302)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:342)
... 26 more
Was it helpful?

Solution

I answer my own question because I found that there is no other question about Websphere, and I want to share my finding with the community. The solution is to add the following xml snippet to the web.xml:

<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

Because ServletContainerInitializer Servlet 3.0 feature seems not working on Websphere.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top