11 Replies Latest reply on Apr 28, 2010 4:56 PM by fischman_98

    richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?

    fischman_98

      To All,

       

      I am receiving this error after I add richfaces .jars and additions to the web.xml.

       

      WITHOUT the richfaces .jars and extensions, the page is rendered.

       

      WITH the richfaces .jars and extensions, I receive the follwoing error.  I'm wondering about the warning (MyFaces Extensions Filter should be configured to execute *AFTER* RichFaces filter. Refer to SRV.6.2.4 section of Servlets specification on how to achieve that.).

       

      I attached the web.xml and the simple .jsp page.


      Thanks!

       

      Matt

       

      Apr 15, 2010 6:17:21 PM org.ajax4jsf.webapp.BaseFilter checkMyFacesExtensionsFilter

      WARNING: MyFaces Extensions Filter should be configured to execute *AFTER* RichFaces filter. Refer to SRV.6.2.4 section of Servlets specification on how to achieve that.

      Apr 15, 2010 6:17:21 PM org.apache.myfaces.renderkit.ErrorPageWriter handleThrowable

      SEVERE: An exception occurred

      javax.faces.FacesException

       

      : java.lang.IllegalStateException: setViewHandler may not be executed after a lifecycle request has been completed

      at org.apache.myfaces.context.ExceptionHandlerImpl.wrap(

      ExceptionHandlerImpl.java:241)

      at org.apache.myfaces.context.ExceptionHandlerImpl.handle(

      ExceptionHandlerImpl.java:156)

      at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(

      LifecycleImpl.java:163)

      at org.apache.myfaces.lifecycle.LifecycleImpl.execute(

      LifecycleImpl.java:93)

      at javax.faces.webapp.FacesServlet.service(

      FacesServlet.java:189)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

      ApplicationFilterChain.java:290)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(

      ApplicationFilterChain.java:206)

      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(

      ExtensionsFilter.java:285)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

      ApplicationFilterChain.java:235)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(

      ApplicationFilterChain.java:206)

      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(

      BaseXMLFilter.java:206)

      at org.ajax4jsf.webapp.BaseFilter.handleRequest(

      BaseFilter.java:290)

      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(

      BaseFilter.java:388)

      at org.ajax4jsf.webapp.BaseFilter.doFilter(

      BaseFilter.java:515)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

      ApplicationFilterChain.java:235)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(

      ApplicationFilterChain.java:206)

      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(

      ExtensionsFilter.java:341)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

      ApplicationFilterChain.java:235)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(

      ApplicationFilterChain.java:206)

      at org.apache.catalina.core.StandardWrapperValve.invoke(

      StandardWrapperValve.java:233)

      at org.apache.catalina.core.StandardContextValve.invoke(

      StandardContextValve.java:191)

      at org.apache.catalina.core.StandardHostValve.invoke(

      StandardHostValve.java:128)

      at org.apache.catalina.valves.ErrorReportValve.invoke(

      ErrorReportValve.java:102)

      at org.apache.catalina.core.StandardEngineValve.invoke(

      StandardEngineValve.java:109)

      at org.apache.catalina.connector.CoyoteAdapter.service(

      CoyoteAdapter.java:293)

      at org.apache.jk.server.JkCoyoteHandler.invoke(

      JkCoyoteHandler.java:190)

      at org.apache.jk.common.HandlerRequest.invoke(

      HandlerRequest.java:291)

      at org.apache.jk.common.ChannelSocket.invoke(

      ChannelSocket.java:769)

      at org.apache.jk.common.ChannelSocket.processConnection(

      ChannelSocket.java:698)

      at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(

      ChannelSocket.java:891)

      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(

      ThreadPool.java:690)

      at java.lang.Thread.run(Unknown Source)

      Caused by:

      java.lang.IllegalStateException: setViewHandler may not be executed after a lifecycle request has been completed

      at org.apache.myfaces.application.ApplicationImpl.setViewHandler(

      ApplicationImpl.java:846)

      at org.ajax4jsf.event.InitPhaseListener.beforePhase(

      InitPhaseListener.java:92)

      at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(

      PhaseListenerManager.java:76)

      at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(

      LifecycleImpl.java:131)

      ... 29 more

      Apr 15, 2010 6:17:21 PM org.apache.myfaces.renderkit.html.util.DefaultAddResource writeMyFacesJavascriptBeforeBodyEnd

      WARNING: MyFaces special javascript could not be retrieved from request-map.

        • 1. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
          nbelaevski

          I've posted issue to MyFaces JIRA on that: https://issues.apache.org/jira/browse/MYFACES-2662

          You can use the following workaround:

           

          - configure AjaxViewHandler in faces-config.xml explicitly:

           

          <application>
               <view-handler>org.ajax4jsf.application.AjaxViewHandler</view-handler>
          </application>
          
          

           

          - define another view handlers (if any) in web.xml:

           

            <context-param>
                 <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                 <param-value>com.sun.facelets.FaceletViewHandler</param-value>
            </context-param>
          
          • 2. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
            fischman_98

            Nick,

             

            Thanks for posting the issue to MyFaces JIRA and thanks for the workaround.

             

            Can you help me with one more item?  I don't get the original error any more, but the page IS NOT displaying.

             

            If I TAKE OUT THE JSF CODE and only leave the jsp in (%= java.util.Calendar.getInstance().get(java.util.Calendar.YEAR)%>), AND reference the page like this http://localhost:8080/ngsimages/index.jsp, it displays.

             

            When I reference the page directing it go use jsf, like this http://localhost:8080/ngsimages/index.jsf, nothing is displayed.

             

            Any Thoughts?  I included the .war file just in case you can check this out.

             

            Matt

             

            Message was edited by: Matthew Fischer  (Replaced .war file)

            • 3. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
              ilya_shaikovsky

              This is one more problem related to MyFaces. It seems not fuly compatible with 1.2.. It fully relies on VDL for build view so it would not works. And using facelets (as in most our examples) there ais no such problem because facelets handle this. We do not digged into the problem initial reasons but the workaround is:

               

                <context-param>
                     <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                     <param-value>org.apache.myfaces.application.jsp.JspViewHandlerImpl</param-value>
                </context-param>
              

               

              But it's highly recommended not to use JSP as view language as it's deprecated by JSF 2.0 specification. And we not plan to support it in 4.x.

              1 of 1 people found this helpful
              • 4. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
                fischman_98

                Ilya,

                 

                This workaround does the trick and solves the problem for me.

                 

                But won't this effect everyone that uses .jsp pages and attempts to migrate to MyFaces 2.x RichFaces 3.3.x (& 4.x)?

                 

                Should this be submitted as a JIRA issue to either;

                     a) add this to the documentation

                AND/OR

                     b) go to the source and resolve the issue?

                 

                BTW: This page is successfully rendered without the richfaces .jar's.

                 

                Thanks.

                 

                Matt

                • 5. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
                  nbelaevski

                  Matt,

                   

                  I've just created https://jira.jboss.org/jira/browse/RFPL-535 to describe this another problem with JSP.

                   

                  Also this affects 3.3.x only, 4.x doesn't run in JSF 1.2 back-compatibility mode, so the problem won't affect it.

                   

                  BTW: This page is successfully rendered without the richfaces .jar's.

                  Filed issue with test case into MyFaces JIRA: https://issues.apache.org/jira/browse/MYFACES-2665

                   

                  Message was edited by: Nick Belaevski

                  • 6. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
                    ilya_shaikovsky

                    b) go to the source and resolve the issue?

                    Actually it looks just as myFAces issue as Mojara works fine with or without RF under JSP or facelets. But I'll describe that at wiki page.

                    • 7. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
                      fischman_98

                      OK...one more issue.

                       

                      I started testing using Facelets since that's the way to go for the future and came up with the following issue.  I included another .war.

                       

                      ISSUE: http://localhost:8080/ngsimages/two.jsf is returning HTTP Status 404 - /ngsimages/two.xhtml .jsf

                       

                      Note: displaying .xhtml extension and appending a <space> and .jsf (see below)

                       

                      The ViewHandler I used for MyFaces 2.0 is below (com.sun.facelets.FaceletViewHandler was not found):

                       

                      <context-param>
                             <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                             <param-value>org.apache.myfaces.view.facelets.FaceletViewHandler</param-value>
                      </context-param>

                      appending two extensions.gif

                       

                      Message was edited by: Matthew Fischer

                      • 8. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
                        nbelaevski

                        Matt,

                         

                        From the wiki page http://community.jboss.org/wiki/RichFaces333andJSF20:

                         

                        RichFaces 3.3.3 does not support JSF 2 built-in facelets (VDL)

                        Facelets 1.1.15 should still be used because of dependencies in RichFaces from the Tag Handlers classes.

                        So, the following should be done:

                         

                        1. Facelets 1.1.15 added to classpath

                        2. VDL view handler disabled

                        <context-param>
                             <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
                             <param-value>true</param-value>
                        </context-param>
                        

                        3. Facelets view handler configured:

                         

                          <context-param>
                               <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                               <param-value>com.sun.facelets.FaceletViewHandler</param-value>
                          </context-param>
                        
                        • 9. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
                          fischman_98

                          Guys,

                           

                          I totally don't want to belabor this issue, and I will only continue with it if it is helping the cause.  So please let me know if this is a helpful thread for testing the new code.

                           

                          I made the changes to the web.xml and I tried jsf-facelets-1.1.15.jar from this repository http://repository.jboss.com/maven2/com/sun/facelets/jsf-facelets/1.1.15/ and also jsf-facelets.jar from this repository https://facelets.dev.java.net/servlets/ProjectDocumentList?folderID=3635&expandFolder=3635&folderID=0 (which is in the attached .war) and both resulted in this error.

                           

                          URL: http://localhost:8080/ngsimages/two.xhtml

                           

                          Error:

                          SEVERE: Servlet.service() for servlet Faces Servlet threw exception
                          java.lang.IllegalStateException: Cannot create a session after the response has been committed
                          at org.apache.catalina.connector.Request.doGetSession(Request.java:2313)
                          at org.apache.catalina.connector.Request.getSession(Request.java:2074)
                          at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
                          at org.apache.myfaces.context.servlet.ServletExternalContextImpl.getSession(ServletExternalContextImpl.java:144)
                          at org.apache.myfaces.context.flash.FlashImpl._getMapFromSession(FlashImpl.java:173)
                          at org.apache.myfaces.context.flash.FlashImpl.getPostbackRequestMap(FlashImpl.java:233)
                          at org.apache.myfaces.context.flash.FlashImpl._removeAllChildren(FlashImpl.java:300)
                          at org.apache.myfaces.context.flash.FlashImpl.doPostPhaseActions(FlashImpl.java:362)
                          at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
                          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                          at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
                          at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                          at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                          at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
                          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
                          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
                          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
                          at java.lang.Thread.run(Unknown Source)

                           

                          Thanks again.

                           

                          Matt

                          • 10. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
                            ilya_shaikovsky

                            In my opinion MyFAces 2.0 is too raw to build application with currently.. :/

                             

                            Problem fixed for me by changing just two servlet mappings to

                             

                             

                            <servlet-mapping>
                            <servlet-name>Faces Servlet</servlet-name>
                            <url-pattern>/faces/*</url-pattern>
                            </servlet-mapping>
                            

                             

                            b.t.w. please additionally check the wiki page. there is limitation on new tags like h:head, h:body, f:ajax limitation present .

                            • 11. Re: richfaces 3.3.3.Final and myfaces 2.0.0-beta-3 Set Up - IllegalStateException web.xml?
                              fischman_98

                              I got it to work that way too.

                               

                              I agree with your assessment, I'm going to wait until we get a little further on down the road before I start the complete redesign for production using 2.0 and RichFaces.

                               

                              Should this be added to the JIRA list too?

                               

                              Ilya & Nick, thanks for all the input (& I'll keep testing!).

                               

                              Matt