3

I am trying to run a sample primefaces 3.1 application using eclipse. When I run I am getting the following exception. I have placed jstl-1.0.2.jar,jsf-impl-2.0.3.jar,jsf-api-2.0.3.jar,primefaces-3.1.jar under WEb-INF/lib folder and index.jsf is placed under /WebContent.

Problem accessing /TestPrime/index.jsf. Reason: 

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

Caused by:
javax.servlet.UnavailableException: java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
    at org.mortbay.jetty.servlet.ServletHolder.makeUnavailable(ServletHolder.java:415)
    at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:458)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72)
    at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29)

My web.xml is as follows:

<web-app version="2.5">
    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" >

    <welcome-file-list>
        <welcome-file>index.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>*.jsf</url-pattern>
    </servlet-mapping>

</web-app>

Update 1

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
    <display-name>Archetype Created Web Application</display-name>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
     <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
    <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>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <mime-mapping>
        <extension>png</extension>
        <mime-type>image/png</mime-type>
    </mime-mapping>
    <welcome-file-list>
        <welcome-file>login.jsf</welcome-file>
    </welcome-file-list>    
</web-app>
Jacob
  • 14,463
  • 65
  • 207
  • 320

1 Answers1

11

It's Jetty's fault. It is somehow not executing the JSF ConfigureListener which is been registered in the JSF TLD file.

Add the following entry to your webapp's web.xml to manually register it:

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

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks for the anseer. I added ` com.sun.faces.config.ConfigureListener ` in web.xml and when I run I am getting error `HTTP ERROR: 404 Problem accessing /TestPrime/faces/login.jsf. Reason: NOT_FOUND -------------------------------------------------------------------------------- Powered by Jetty:// ` – Jacob Feb 14 '12 at 12:27
  • That's a different problem. The resource is just not there where you expect it is. Either the URL is wrong or the resourse has not been deployed. Your initial problem is solved. Ask a new question if you stucks. – BalusC Feb 14 '12 at 12:28
  • Thanks a lot. BalusC. I need to figure out why I am getting `HTTP ERROR: 404 Problem accessing /TestPrime/faces/login.jsf. Reason: NOT_FOUND` error. – Jacob Feb 14 '12 at 13:42