Question

I am trying to run a JSF 2.0 webapp using Apache MyFaces 2.1.7 on a Tomcat 6 webserver. The App uses Tomahawk 1.1.11 and expression language 2.2 (el-impl-2.2.jar). For that purpose I've put the myfaces-api and myfaces-impl into Tomcats lib folder and exchanged Tomcats el-api.jar for the 2.2 variant.

When I call the first page of the app I always get the error:

java.lang.IllegalStateException: No Factories configured for this Application. This 
happens if the faces-initialization does not work at all - make sure that you properly 
include all configuration settings necessary for a basic faces application and that all 
the necessary libs are included. Also check the logging output of your web application 
and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use 
some special web-containers which do not support registering context-listeners via TLD 
files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
 <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

javax.faces.FactoryFinder._getFactory(FactoryFinder.java:286)
javax.faces.FactoryFinder.getFactory(FactoryFinder.java:206)
javax.faces.webapp.FacesServlet.init(FacesServlet.java:116)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:679)

I definitely have the xml snippet mentioned in my web.xml. I tried to debug into the code and found that registeredFactoryNames on line 267 of javax.faces.FactoryFinder is empty which causes the error. I however do not understand why this is the case. What should be in there and how do I get it there?

The funny thing is that the webapp runs perfectly using embedded jetty 8. So it must be some dependency issue.

Hope someone with more insight into all of this can help me here.

Was it helpful?

Solution

Ok

I found the problem. The error results from having the myfaces-api.jar twice on your classpath. So for me the problem was I placed the myfaces-api.jar in the tomcat lib folder and in the WEB-INF/lib folder of the webapp.

While using an embedded tomcat with maven I had the myfaces-api.jar in the dependencies of the whole application and in the dependencies of the tomcat6-maven-plugin with scope compile both. I changed the scope from compile to provided in the global dependencies section and it worked.

OTHER TIPS

I think it could be solved just adding an empty faces-config.xml file under /WEB-INF/ folder, to indicate the application uses JSF and MyFaces continue the initialization step. See the class org.apache.myfaces.ee6.MyFacesContainerInitializer for details.

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