3 Replies Latest reply: Jan 11, 2013 8:30 AM by Sujay Patil RSS

    Exception when using Custom FacesServlet

    Sujay Patil
      Hello,

      I am getting IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory., when I am using custom FacesServlet. I have created Custom FacesServlet as shown below,
      public class HelloWorldFacesServlet extends HttpServlet {
          private FacesServlet delegate;
          
          public void init(ServletConfig servletConfig) throws ServletException {
              delegate = new FacesServlet();
              delegate.init(servletConfig);
          }
          public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
                  delegate.service(request, response);
          }
      }
      I am getting below exception, Exception is thrown when I am calling delegate.init(servletConfig);
      weblogic.application.ModuleException: [HTTP:101216]Servlet: "Faces Servlet" failed to preload on startup in Web application: "HelloWorld".
      java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory. 
           at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:996)
           at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:331)
           at javax.faces.webapp.FacesServlet.init(FacesServlet.java:219)
           at *com.helloworld.servlets.HelloWorldFacesServlet.init(HelloWorldFacesServlet.java:72)*
           at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
           at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
           at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
           at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
           at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
           at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
           at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
           at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
           at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
           at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
           at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
           at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
           at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
      - Sujay
        • 1. Re: Exception when using Custom FacesServlet
          Frank Nimphius-Oracle
          Hi,

          if you Google for it you find hints like this: http://stackoverflow.com/questions/10019587/getting-error-with-jsf2-backup-for-factory-javax-faces-context-facescontex

          Frank
          • 2. Re: Exception when using Custom FacesServlet
            Sujay Patil
            Hello Frank,

            This is the first thing I did :). But one thing, the web.xml shared in the Post of Stackoverflow, javax.faces.webapp.FacesServlet is used. I am getting this error when I am using HelloWorldFacesServlet. In my HelloWorldFacesServlet, I am delegating request to FacesServlet after my logic.

            I already defined the ConfigureListener in my web.xml.
            <listener>
                    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
            </listener>
            This doesn't solve the issue.

            - Sujay

            Edited by: Sujay Patil on Dec 10, 2012 2:00 AM
            • 3. Re: Exception when using Custom FacesServlet
              Sujay Patil
              I am able to resolve this issue using Dummy Faces Servlet.

              I added generic FacesServlet as Dummy FacesServlet and I used my custom FacesServlet as main FacesServlet.
              <servlet>
                <servlet-name>Dummy Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
              </servlet>
              <servlet>
                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>com.helloworld.servlets.HelloWorldFacesServlet</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>
              But there should be way to provide custom FacesServlet. This is not a proper solution.

              - Sujay