Could not find Factory: javax.faces.application.ApplicationFactory

Hi, I am trying to use the following technologies together:

  • JSF 2.1.0
  • ICEFaces 2.0.2 , which matches their documentation, works great with JSF 2.1.x
  • Tomcat 6

my web.xml :

<?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_2_5.xsd" version="2.5"> <display-name>appName</display-name> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:META-INF/spring/applicationContext.xml </param-value> </context-param> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param> <welcome-file-list> <welcome-file>/</welcome-file> </welcome-file-list> <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> <context-param> <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param> <servlet> <servlet-name>Resource Servlet</servlet-name> <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Resource Servlet</servlet-name> <url-pattern>/xmlhttp/*</url-pattern> </servlet-mapping> <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> </web-app> 

but when trying to run my application, I got the following exception:

 SEVERE: Unexpected exception when attempting to tear down the Mojarra runtime java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:815) at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:317) at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:112) at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:329) at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4245) at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4886) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4750) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 

any ideas why?

+4
source share
2 answers

JSF 2.1 requires a Servlet 3.0 compatible container, but Tomcat 6 is Servlet 2.5 compatible . You have 2 options:

  • Migrating JSF 2.1 to JSF 2.0 (Mojarra 2.0 is currently in version 2.0.6).
  • Upgrade Tomcat 6.0 to Tomcat 7.0 (and change the web.xml root declaration compatible with Servlet 3.0).

If you choose option 2 (upgrade to Tomcat 7.0), then you should upgrade Mojarra 2.1.0, at least to Mojarra 2.1.1 (this is already in 2.1.3). This is necessary because Mojarra 2.1.0 contains an error in the annotation scanner, which makes it incompatible with Tomcat and Jetty.

See also:

+8
source

I solved this problem using two approaches:

1. Two remote jsf versions were removed (for example, jsf 1.x or jsf2.x) or two different jsf implementations were removed (mojarra jsf or myfaces) from the project. And I used only one implementation of either mojarra (or myfaces), but not both. I did the same in the case of jsf different version jars (for example, jsf 2.x jars were used), and not jsf 1.x.

2. Change the annotation of @ManagedBean from the interfaces.

-1
source

All Articles