10 Replies Latest reply on Apr 17, 2013 3:27 PM by nickarls

    Myfaces error (IllegalStateException) in eap6

    bes.comcom

      Some background:  I've been working for a few weeks now converting an old jboss 4.0.3 application to AS7 (more specifically eap6.1).

      I've worked through all of the basic configuration changes (jpa, jms, jca, etc) with very few problems.  I'm not working with the web layer.

       

      This application uses myfaces/tomahawk that I'm converting from jsf1 to jsf2.

      I've set up the web context to use the jboss param org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL = true and I've embedded the myfaces jarfiles in /WEB_INF/lib

       

      I am getting the following error:

       

      JBWEB000306: Exception sending context destroyed event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener: java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory.

              at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1010) [jboss-jsf-api_2.1_spec-2.1.18.Final.jar:2.1.18.Final]

              at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:342) [jboss-jsf-api_2.1_spec-2.1.18.Final.jar:2.1.18.Final]

              at org.apache.myfaces.context.servlet.FacesContextImplBase.getApplication(FacesContextImplBase.java:153) [myfaces-impl-2.0.15.jar:2.0.15]

              at org.apache.myfaces.context.servlet.FacesContextImplBase.getELContext(FacesContextImplBase.java:204) [myfaces-impl-2.0.15.jar:2.0.15]

              at javax.faces.component.UIViewRoot.setLocale(UIViewRoot.java:1455) [jboss-jsf-api_2.1_spec-2.1.18.Final.jar:2.1.18.Final]

              at org.apache.myfaces.webapp.AbstractFacesInitializer._createFacesContext(AbstractFacesInitializer.java:477) [myfaces-impl-2.0.15.jar:2.0.15]

              at org.apache.myfaces.webapp.AbstractFacesInitializer.initShutdownFacesContext(AbstractFacesInitializer.java:459) [myfaces-impl-2.0.15.jar:2.0.15]

              at org.apache.myfaces.webapp.StartupServletContextListener.contextDestroyed(StartupServletContextListener.java:153) [myfaces-impl-2.0.15.jar:2.0.15]

              at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3427) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

              at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3920) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3839) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

              at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.2.0.Alpha1-redhat-4.jar:7.2.0.Alpha1-redhat-4]

              at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.2.0.Alpha1-redhat-4.jar:7.2.0.Alpha1-redhat-4]

              at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.2.0.Alpha1-redhat-4.jar:7.2.0.Alpha1-redhat-4]

              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_13]

              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_13]

              at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_13]

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_13]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_13]

              at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_13]

              at org.jboss.threads.JBossThread.run(JBossThread.java:122)

       

       

      Any pointers on where to start looking for a root cause?  I've tried everything I personally could think of :/

        • 1. Re: Myfaces error (IllegalStateException) in eap6
          ctomc

          Hi,

           

          7.2 / eap 6.1 has new way how to use myfaces.

           

          see https://community.jboss.org/wiki/DesignOfAS7Multi-JSFFeature for more info.

           

           

          --

          tomaz

          • 2. Re: Myfaces error (IllegalStateException) in eap6
            bes.comcom

            I read that entire thread before even coming here.  It seems that stan had some reservations of this working fully with the new module layout, etc.

            That was why I went with the WAR_BUNDLES_JSF_IMPL option.  So thank you, but that didn't really answer my question as the bundled into the war is still a valid method currently.

            • 3. Re: Myfaces error (IllegalStateException) in eap6
              ssilvert

              Show me your web.xml.

               

              There is something wrong because it really should not be loading classes from jboss-jsf-api_2.1_spec-2.1.18.Final.jar with WAR_BUNDLES_JSF_IMPL.

               

              That being said, it is still possible because that module is available from the web subsystem and we are in the process of tearning down the context.  This brings up another question.  Why is MyFaces creating a FacesContext during the context destroyed event?

               

              Stan

              • 4. Re: Myfaces error (IllegalStateException) in eap6
                bes.comcom

                Here's the pertinent portion of my web.xml

                 

                <?xml version="1.0" ?>

                <web-app xmlns="http://java.sun.com/xml/ns/j2ee"

                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

                         version="2.4">

                    <distributable />

                 

                 

                    <!-- <listener>

                        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>

                    </listener>-->

                   

                    <context-param>

                      <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>

                      <param-value>true</param-value>

                    </context-param>

                    <session-config>

                        <!-- HTTP Session timeout, in minutes -->

                                  <session-timeout>180</session-timeout>

                    </session-config>

                   

                        <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>

                       

                        <servlet-mapping>

                            <servlet-name>Faces Servlet</servlet-name>

                            <url-pattern>*.faces</url-pattern>

                        </servlet-mapping>

                              <filter>

                                        <filter-name>MyFacesExtensionsFilter</filter-name>

                                        <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>

                                  <init-param>

                                      <param-name>maxFileSize</param-name>

                                      <param-value>20m</param-value>

                                  </init-param>

                              </filter>

                   

                              <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages  -->

                              <filter-mapping>

                                  <filter-name>MyFacesExtensionsFilter</filter-name>

                                  <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->

                                  <servlet-name>Faces Servlet</servlet-name>

                              </filter-mapping>

                   

                              <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.)  -->

                              <filter-mapping>

                                  <filter-name>MyFacesExtensionsFilter</filter-name>

                                  <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>

                              </filter-mapping>   

                   

                              <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages  -->

                              <filter-mapping>

                                  <filter-name>MyFacesExtensionsFilter</filter-name>

                                  <url-pattern>*.jsf</url-pattern>

                              </filter-mapping>

                </web-app>

                 

                 

                 

                I snipped out the app specific servlet definitions as they only reference local webtier classes.

                • 5. Re: Myfaces error (IllegalStateException) in eap6
                  glennk

                  I have been scouring the internet/chat for weeks with this same issue. I'm surprised I didn't find this post earlier. Indeed, JBOSS "should not be loading classes from jboss-jsf-api_2.1_spec-2.1.18.Final.jar with WAR_BUNDLES_JSF_IMPL" and yet is is for some reason.

                  I have not been able to get my application enabled with myfaces components. I've tried the bundled jar, everything but the bundled jar, many different configurations, finally after talking my situation through with someone on xChat, I was told to ambush stsilvert.

                  I am very interested in Stan Silvert's take on this situation. How can we get MyFaces to run on JBOSS 7.2!?

                  Again, this link: https://community.jboss.org/wiki/DesignOfAS7Multi-JSFFeature does not provide the solution.

                  Could it be that somewhere in some file/jar, the JSF versions don't match?

                  Thank you very much for your time.

                  • 6. Re: Myfaces error (IllegalStateException) in eap6
                    bes.comcom

                    Looking further up the error tree, I found this error.  I wonder if it is related.

                     

                    SEVERE [javax.faces] (ServerService Thread Pool -- 78) Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory. Attempting to find backup.

                     

                    So it looks like the error I originally posted is only being thrown because this line here says its off looking for a backup factory.  Could this be a configuration issue?  If so, I've read nothing in the documentation that leads me to what it could be.

                    • 7. Re: Myfaces error (IllegalStateException) in eap6
                      bes.comcom

                      Stan Silvert wrote:

                       

                      <snip>  Why is MyFaces creating a FacesContext during the context destroyed event?

                       

                      Stan

                      I know why it was creating a destroy event, it was trying to bring the app back down. Just above that it threw the same Exception during the Initialize Event    

                      09:25:10,943 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/pz3]] (ServerService Thread Pool -- 106) JBWEB000287: Exception sending context initialized event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener: java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory.

                              at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1010) [jboss-jsf-api_2.1_spec-2.1.18.Final.jar:2.1.18.Final]

                              at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:342) [jboss-jsf-api_2.1_spec-2.1.18.Final.jar:2.1.18.Final]

                              at org.apache.myfaces.context.servlet.FacesContextImplBase.getApplication(FacesContextImplBase.java:153) [myfaces-impl-2.0.15.jar:2.0.15]

                              at org.apache.myfaces.context.servlet.FacesContextImplBase.getELContext(FacesContextImplBase.java:204) [myfaces-impl-2.0.15.jar:2.0.15]

                              at javax.faces.component.UIViewRoot.setLocale(UIViewRoot.java:1455) [jboss-jsf-api_2.1_spec-2.1.18.Final.jar:2.1.18.Final]

                              at org.apache.myfaces.webapp.AbstractFacesInitializer._createFacesContext(AbstractFacesInitializer.java:477) [myfaces-impl-2.0.15.jar:2.0.15]

                              at org.apache.myfaces.webapp.AbstractFacesInitializer.initStartupFacesContext(AbstractFacesInitializer.java:449) [myfaces-impl-2.0.15.jar:2.0.15]

                              at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:111) [myfaces-impl-2.0.15.jar:2.0.15]

                              at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

                              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

                              at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.2.0.Alpha1-redhat-4.jar:7.2.0.Alpha1-redhat-4]

                              at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.2.0.Alpha1-redhat-4.jar:7.2.0.Alpha1-redhat-4]

                              at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.2.0.Alpha1-redhat-4.jar:7.2.0.Alpha1-redhat-4]

                              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_13]

                              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_13]

                              at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_13]

                              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_13]

                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_13]

                              at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_13]

                              at org.jboss.threads.JBossThread.run(JBossThread.java:122)

                       

                      But as you can see, the jboss-jsf-api_2.1_spec-2.1.18.Final.jar:2.1.18.Final is still in the stack, this is odd (as you mentioned).

                      • 8. Re: Myfaces error (IllegalStateException) in eap6
                        bes.comcom

                        wow, don't know why I didn't look for this sooner.  In my standalone-full.xml the following line was in there:

                                <subsystem xmlns="urn:jboss:domain:jsf:1.0"/>

                         

                        It was an empty element, but it was obviously causing a conflict.  As soon as I removed it the Factory method was called fine on the myfaces impl and the context loaded.

                         

                        Is this a bug that that statement (in the config by default) doesn't work correctly with WAR_BUNDLES_JSF_IMPL?

                        • 9. Re: Myfaces error (IllegalStateException) in eap6
                          glennk

                          Although removing that line did help, I now receive this error:

                           

                          SEVERE [org.apache.myfaces.webapp.AbstractFacesInitializer] (ServerService Thread Pool -- 72) An error occured while initializing MyFaces: Class org.jboss.as.weld.webtier.jsf.WeldApplicationFactory is no javax.faces.application.ApplicationFactory: java.lang.IllegalArgumentException: Class org.jboss.as.weld.webtier.jsf.WeldApplicationFactory is no javax.faces.application.ApplicationFactory

                                    at javax.faces.FactoryFinder.newFactoryInstance(FactoryFinder.java:354) [myfaces-bundle-2.1.11.jar:2.1.11]

                           

                          Also, implementing Stan Silvert's help of making myfaces the default JSF implementation (via https://issues.jboss.org/browse/AS7-5649) did not affect the above error.

                          Any ideas as to why that would be?

                          Is there more to "bundling the war" then importing jars into my library in Netbeans? They are definitely called that way, just wanted to make sure. I've tried manually dropping the jars into WEB_INF/lib with no different effect.

                          Thank you

                           

                          bes, what jars do you have where? I am trying to get myfaces working on 7.2 (eap 6.1 nightly) with myfaces-bundle-2.1.11, tomahawk 1.1.9, and commons beanutils/codec/collections/digester/logging

                          • 10. Re: Myfaces error (IllegalStateException) in eap6
                            nickarls

                            Is this the https://issues.jboss.org/browse/AS7-1628 ? (there is a a link to a workaround)