jQuery in Action, 2nd edition*
The moose likes JSF and the fly likes could not find Factory: javax.faces.context.FacesContextFactory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "could not find Factory: javax.faces.context.FacesContextFactory" Watch "could not find Factory: javax.faces.context.FacesContextFactory" New topic
Author

could not find Factory: javax.faces.context.FacesContextFactory

Jeetu Das
Greenhorn

Joined: May 12, 2012
Posts: 12
Hi Friends,
I am new no JSF application .
I facing a problem when i am starting apache tomcat server with JSF application deployed in eclipse evviroment.
I have deplpyed the related jars in the lib folder of my web app.

Please help.

Web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>HelloWorldJSF</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<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>



Error:

java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory




java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:263)
at javax.faces.webapp.FacesServlet.init(FacesServlet.java:142)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
May 12, 2012 3:19:52 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /MyFirstJSFApp threw load() exception
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:263)
at javax.faces.webapp.FacesServlet.init(FacesServlet.java:142)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
May 12, 2012 3:19:52 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.0.3 (FCS b03) for context '/HelloWorldJSF'
May 12, 2012 3:19:53 PM com.sun.faces.config.ConfigManager initialize
INFO: Unsanitized stacktrace from failed start...
java.lang.IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory
at javax.faces.FactoryFinder.validateFactoryName(FactoryFinder.java:650)
at javax.faces.FactoryFinder.setFactory(FactoryFinder.java:295)
at com.sun.faces.config.processor.FactoryConfigProcessor.setFactory(FactoryConfigProcessor.java:279)
at com.sun.faces.config.processor.FactoryConfigProcessor.processFactories(FactoryConfigProcessor.java:235)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:189)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:332)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:220)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
May 12, 2012 3:19:53 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! javax.faces.context.ExceptionHandlerFactory
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:351)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:220)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory
at javax.faces.FactoryFinder.validateFactoryName(FactoryFinder.java:650)
at javax.faces.FactoryFinder.setFactory(FactoryFinder.java:295)
at com.sun.faces.config.processor.FactoryConfigProcessor.setFactory(FactoryConfigProcessor.java:279)
at com.sun.faces.config.processor.FactoryConfigProcessor.processFactories(FactoryConfigProcessor.java:235)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:189)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:332)
... 16 more
May 12, 2012 3:19:53 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
May 12, 2012 3:19:53 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/HelloWorldJSF] startup failed due to previous errors
May 12, 2012 3:19:53 PM com.sun.faces.config.ConfigureListener contextDestroyed
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.getFactory(FactoryFinder.java:263)
at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:104)
at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:312)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
May 12, 2012 3:19:53 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/HelloWorldJSF] created a ThreadLocal with key of type [com.sun.faces.util.Util$1] (value [com.sun.faces.util.Util$1@140984b]) and a value of type [java.util.HashMap] (value [{com.sun.faces.patternCache={ = }}]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
May 12, 2012 3:19:53 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8088
May 12, 2012 3:19:53 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
May 12, 2012 3:19:53 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/32 config=null
May 12, 2012 3:19:53 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1572 ms
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

Welcome to the JavaRanch, Jeetu!

JSF normally comes in 2 core libaries: the jsf-api jar and the jsf-impl jar.

In full-stack JEE servers, only the jsf-api jar has to be included in your WAR's WEB-INF/lib directory. That's because the jsf-impl jar (or its equivalent) is actually part of the webaapp server.

Tomcat is different. It is not a full-stack server and it does not contain jsf-impl code. So you also have to include a jsf-impl.jar in WEB-INF/lib.

Note that if you use a full-stack server such as JBoss that embeds a copy of Tomcat inside it, the jsf-impl jar is included as part of the full-stack JEE implementation, so in cases like JBoss, you don't have to include jsf-impl in the WAR. You only need it when running a stand-alone Tomcat.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jeetu Das
Greenhorn

Joined: May 12, 2012
Posts: 12
Thanks a lot Tim , Now its worked fine .

I have one doubt . I have to add jsf-api jar, jsf-impl jar jstl jar .
I have tried with jsf-api jar, jsf-impl jar two jars , not worked properly and after adding of jstl.jar worked fine .

As per your info jstl jar is not required , Can you please tell me why its not working without jstl.jar .


Anyway Thankls a lot , Your info helped me in running the app sucessfully.


Jeetu
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

Actually, jstl.jar is required. So you did it right.

I discourage using JSTL code in JSF user-created View definitions, but at the moment JSF itself requires jstl.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: could not find Factory: javax.faces.context.FacesContextFactory
 
Similar Threads
Cannot bring up a html page using tomcat 6.0
richfaces integration issue
error
Tomcat startup problems
Error when trying to upload a file using Jersey