1 2 Previous Next 18 Replies Latest reply on May 4, 2012 8:14 AM by andre.eugenio

    Illegal attempt to set ViewHandler after a response has been rendered

    dpnascimento

      Hi all!!!

       

      I got some problems today!

       

      Everytime I tryed to use my applicatin, I got the stack trace below.

       

       

      javax.servlet.ServletException: Illegal attempt to set ViewHandler after a response has been rendered.

                javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)

                org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)

                org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)

                org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)

                org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

      root cause

      java.lang.IllegalStateException: Illegal attempt to set ViewHandler after a response has been rendered.

                com.sun.faces.application.ApplicationImpl.setViewHandler(ApplicationImpl.java:563)

                org.ajax4jsf.event.InitPhaseListener.beforePhase(InitPhaseListener.java:92)

                com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)

                com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)

                com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:111)

                com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)

                org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)

                org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)

                org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)

                org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

      note The full stack trace of the root cause is available in the Apache Tomcat/6.0.30 logs.

       

       

      The strange is that if I remove the richfaces jars of my application everything is gonna rigth.

       

      Anybody can help me?

       

      Regards.

      Daniel

        • 1. Illegal attempt to set ViewHandler after a response has been rendered
          ilya40umov

          Please, post your RF version, and all other frameworks you are using, also post your web.xml

          • 2. Illegal attempt to set ViewHandler after a response has been rendered
            dpnascimento

            Hi Ilya,

             

            thanks for help me.

             

            Let's see.

             

            My RF version is 3.3

             

            Also, I'm using: JSF1.2, JPA, Hibernate, JUnit, Log4J

             

            You can see below all jars that is in my application

             

            antlr-2.7.6.jar

            commons-beanutils-1.8.3.jar

            commons-collections-3.1.jar

            commons-collections-3.2.1.jar

            commons-digester-2.1.jar

            commons-logging-1.1.1.jar

            dom4j-1.6.1.jar

            el-ri.jar

            hibernate3.jar

            hibernate-jpa-2.0-api-1.0.0.Final.jar

            hsqldb.jar

            javassist.jar

            javassist-3.12.0.GA.jar

            jsf-api.jar

            jsf-impl.jar

            jstl.jar

            jta-1.1.jar

            junit-4.8.2.jar

            log4j-1.2.16.jar

            on-load-1.0.jar

            servlet-api.jar

            slf4j-api-1.6.1.jar

            sqljdbc4.jar

            standard.jar

             

            richfaces-api-3.3.3.Final.jar

            richfaces-impl-3.3.3.Final.jar

            richfaces-ui-3.3.3.Final.jar

             

             

            Below the content of my web.xml file:

             

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

                version="2.5">

             

                <display-name>Ares Performance Suite - Beta version</display-name>

             

                <welcome-file-list>

                    <welcome-file>login.jsf</welcome-file>

                </welcome-file-list>

             

                <context-param>

                    <param-name>org.richfaces.SKIN</param-name>

                    <param-value>blueSky</param-value>

                </context-param>

             

                <context-param>

                    <param-name>org.richfaces.CONTROL_SKINNING</param-name>

                    <param-value>enable</param-value>

                </context-param>

             

                <context-param>

                    <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>

                    <param-value>com.sun.facelets.FaceletViewHandler</param-value>

                </context-param>

             

                <context-param>

                    <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>

                    <param-value>false</param-value>

                </context-param>

             

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

             

                <filter>

                    <display-name>RichFaces Filter</display-name>

                    <filter-name>richfaces</filter-name>

                    <filter-class>org.ajax4jsf.Filter</filter-class>

                </filter>

             

                <filter-mapping>

                    <filter-name>richfaces</filter-name>

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

                    <dispatcher>REQUEST</dispatcher>

                    <dispatcher>FORWARD</dispatcher>

                    <dispatcher>INCLUDE</dispatcher>

                </filter-mapping>

             

                <listener>

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

                </listener>

             

                <!-- <context-param> <param-name>onload-config</param-name> <param-value>/WEB-INF/onload-config.xml</param-value>

                    </context-param> -->

            </web-app>

             

             

            Also, my faces-config.xml

             

            <?xml version="1.0" encoding="UTF-8"?>

            <faces-config 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-facesconfig_1_2.xsd"

                version="1.2">

               

                <!-- Definicao do arquivo de mensagens -->

                <application>

                    <locale-config>           

                       <default-locale>pt_BR</default-locale>

                       <supported-locale>pt_BR</supported-locale>

                       <supported-locale>en_US</supported-locale>

                    </locale-config>

                    <resource-bundle>

                        <base-name>br.com.aresitsolutions.aps.resources.jsp.messages</base-name>

                        <!-- Var define nome do mapa de variaveis que contem as mensagens -->

                        <var>msgs</var>

                    </resource-bundle>

                </application>   

             


                <lifecycle>

                    <phase-listener>net.sf.jsfcomp.onload.OnLoadPhaseListener</phase-listener>

                </lifecycle>


                <managed-bean>

                    <managed-bean-name>loginBean</managed-bean-name>

                    <managed-bean-class>br.com.aresitsolutions.aps.controller.LoginBean</managed-bean-class>

                    <managed-bean-scope>session</managed-bean-scope>

                </managed-bean>

             

                <navigation-rule>

                    <from-view-id>/login.jsp</from-view-id>

                    <navigation-case>

                        <from-outcome>loginErro</from-outcome>

                        <to-view-id>/login.jsp</to-view-id>

                    </navigation-case>

                    <navigation-case>

                        <from-outcome>loginSucesso</from-outcome>

                        <to-view-id>/principal.jsp</to-view-id>

                    </navigation-case>

                </navigation-rule>

               

            </faces-config>

             

            If you need any more information, please, let me know.

             

            Regards.

            Daniel

            • 3. Illegal attempt to set ViewHandler after a response has been rendered
              ilya40umov

              I think that if you are not using Facelets you should remove these two parameters:

                  <context-param>

                      <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>

                      <param-value>com.sun.facelets.FaceletViewHandler</param-value>

                  </context-param>

               

                  <context-param>

                      <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>

                      <param-value>false</param-value>

                  </context-param>

              1 of 1 people found this helpful
              • 4. Illegal attempt to set ViewHandler after a response has been rendered
                dpnascimento

                Cool!

                 

                I have changed the web.xml file.

                 

                But I still continue having the same problem.

                 

                Look.

                 

                type Exception report

                 

                message

                description The server encountered an internal error () that prevented it from fulfilling this request.

                 

                exception

                javax.servlet.ServletException: Illegal attempt to set ViewHandler after a response has been rendered.
                     javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)
                     org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
                     org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                     org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                     org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

                 

                root cause

                java.lang.IllegalStateException: Illegal attempt to set ViewHandler after a response has been rendered.
                     com.sun.faces.application.ApplicationImpl.setViewHandler(ApplicationImpl.java:563)
                     org.ajax4jsf.event.InitPhaseListener.beforePhase(InitPhaseListener.java:92)
                     com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
                     com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
                     com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:111)
                     com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                     javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
                     org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
                     org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                     org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                     org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

                 

                note The full stack trace of the root cause is available in the Apache Tomcat/6.0.30 logs.

                • 5. Illegal attempt to set ViewHandler after a response has been rendered
                  ilya40umov

                  1) Describe in more detail when are you getting this error(some code sample etc).

                  2) Make sure that you are using jsf 1.2

                  • 6. Re: Illegal attempt to set ViewHandler after a response has been rendered
                    dpnascimento

                    I got this error every time I tryed to access my application.

                     

                    I type the URL in browser, http://localhost:8080/aps-web/index.jsf, and got the exception in the sequence.

                     

                    I also, created a simple project (without JPA and Hibernate) as example, to try to discover what is happening, but I got the same problem.

                     

                    One interesting point, if I remove the RF jars, everything works fine.

                    • 7. Illegal attempt to set ViewHandler after a response has been rendered
                      ilya40umov

                      Ok. Let's try it in the following way:

                      Go here http://www.jboss.org/richfaces/download/stable.html and download richfaces-examples. Try to run this application and if it will work find the differences between your jars/configs and jars/configs from the example.

                      • 8. Re: Illegal attempt to set ViewHandler after a response has been rendered
                        dpnascimento

                        I see the example.

                         

                        But I'm afraid it's too different from my world.

                        • 9. Re: Illegal attempt to set ViewHandler after a response has been rendered
                          dpnascimento

                          Well...

                           

                          I do a little different, because the photoalbum is running under JBoss, and my app server is Apache Tomcat.

                           

                          I use to follow this tutorial.

                           

                          http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html_single/#SimpleJSFapplicationwithRichFaces

                           

                          What do you think?

                          • 10. Re: Illegal attempt to set ViewHandler after a response has been rendered
                            ilya40umov

                            I think that you definetly have some kind of problem with jars versions. Where did you get JSF jars?

                            • 11. Illegal attempt to set ViewHandler after a response has been rendered
                              andre.eugenio

                              Im not sure if the problem is related, but I had the same problem when upgraded my jsf version from 2.0.2 to 2.0.4 (downloaded from http://javaserverfaces.java.net/download.html).

                               

                              PS. RF 3.3.3 Final, Seam 2.2.1

                               

                              /peace

                              • 12. Illegal attempt to set ViewHandler after a response has been rendered
                                dpnascimento
                                • 13. Re: Illegal attempt to set ViewHandler after a response has been rendered
                                  ilya40umov

                                  You have two options:

                                  - download and use Mojarra 1.2_15(When you will have JSF 1.2)

                                  - or read this article http://community.jboss.org/wiki/RichFaces333andJSF20

                                  1 of 1 people found this helpful
                                  • 14. Re: Illegal attempt to set ViewHandler after a response has been rendered
                                    dpnascimento

                                    Thanks Ilya!!!

                                     

                                    Everything is working fine now!

                                    1 2 Previous Next