4 Replies Latest reply on Apr 24, 2012 11:59 AM by Phanor Coll

    RichFaces 4.2.1 SEVERE ERROR with <rich:select> and <f:selectItems>

    Phanor Coll Newbie

      Im trying to build a form using jsf 2 richfaces 4.2.1 and jbossAS 7.1.1 but I get a SEVERE error when using rich:select

       

      this is the form

       

       

       

       

      web.xml

       

       

      <?xml version="1.0"?>
      <web-app version="3.0" 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_3_0.xsd">
       <display-name>vuppam2</display-name>
       <context-param>
        <description>JMS API</description>
        <param-name>org.richfaces.push.jms.enabled</param-name>
        <param-value>true</param-value>
       </context-param>
       <context-param>
        <param-name>org.richfaces.skin</param-name>
        <param-value>blueSky</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>
       <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
       </servlet-mapping>
       <welcome-file-list>
        <welcome-file>index.jsf</welcome-file>
       </welcome-file-list>
      </web-app>
      

       

      Im loading data to the rich:select component from a Database with Hibernate..

      but when I load the page in my browser (firefox-chrome), I see the rich:select component with the data from the database, but I get this HUGE ERROR

       

       

      00:04:43,072 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-3) Error Rendering View[/solicitud.xhtml]: java.lang.IllegalStateException: Cannot create a session after the response has been committed
              at org.apache.catalina.connector.Request.doGetSession(Request.java:2636) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.connector.Request.getSession(Request.java:2375) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:841) [jbossweb-7.0.13.Final.jar:]
              at com.sun.faces.context.ExternalContextImpl.getSession(ExternalContextImpl.java:155) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at javax.faces.context.ExternalContextWrapper.getSession(ExternalContextWrapper.java:396) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
              at com.sun.faces.renderkit.ServerSideStateHelper.writeState(ServerSideStateHelper.java:175) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:122) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:166) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:419) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
              at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]
      
      00:04:43,082 INFO  [javax.enterprise.resource.webcontainer.jsf.context] (http--127.0.0.1-8080-3) Exception when handling error trying to reset the response.: java.lang.IllegalStateException: Cannot create a session after the response has been committed
              at org.apache.catalina.connector.Request.doGetSession(Request.java:2636) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.connector.Request.getSession(Request.java:2375) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:841) [jbossweb-7.0.13.Final.jar:]
              at com.sun.faces.context.ExternalContextImpl.getSession(ExternalContextImpl.java:155) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at javax.faces.context.ExternalContextWrapper.getSession(ExternalContextWrapper.java:396) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
              at com.sun.faces.renderkit.ServerSideStateHelper.writeState(ServerSideStateHelper.java:175) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:122) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:166) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:419) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
              at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]
      
      00:04:43,090 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/vuppam2].[Faces Servlet]] (http--127.0.0.1-8080-3) 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:2636) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.connector.Request.getSession(Request.java:2375) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:841) [jbossweb-7.0.13.Final.jar:]
              at com.sun.faces.context.ExternalContextImpl.getSession(ExternalContextImpl.java:155) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at javax.faces.context.ExternalContextWrapper.getSession(ExternalContextWrapper.java:396) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
              at com.sun.faces.renderkit.ServerSideStateHelper.writeState(ServerSideStateHelper.java:175) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:122) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:166) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:419) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.7-jbossorg-2.jar:]
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
              at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]
      

       

       

      If I remove the rich:select component, the form renders without a problem..

        • 1. Re: RichFaces 4.2.1 SEVERE ERROR with <rich:select> and <f:selectItems>
          Luis Garcia Newbie

          Are using a Bean Method to populate your rich:selectItems?

          Do you have a bean.xml in the WEB-INF of your WAR?

          • 2. Re: RichFaces 4.2.1 SEVERE ERROR with <rich:select> and <f:selectItems>
            Phanor Coll Newbie

            Im using a @Stateless Bean

             

            @Stateless

            @ManagedBean(name = "crearSolicitud")

            public class Solicitud {

             

                private String fecha;

                private Integer municipio;

                private Integer parroquia;

             

                @NotEmpty(message = "Debe Ingresar su nombre")

                private String solicitante;

             

                @NotEmpty(message = "Debe Ingresar el nombre de su organizacion")

                private String organziacion;

             

                @NotEmpty(message = "Debe Ingresar la direccion del donde se genera el problema")

                private String direccion;

             

                @Email(message = "Verifique su correo")

                @NotEmpty(message = "Debe Ingresar su correo")

                private String email;

             

                @NotEmpty(message = "Debe Ingresar la descripcion del problema")

                private String reporte;

               

                my list for the rich:select component

                private List<Municipio> listadoMunicipios;

             

                public Solicitud() {}

             

                @PostConstruct

                public void init() {

                    MunicipioParroquia listaMuni=new MunicipioParroquia();

                    this.listadoMunicipios=listaMuni.listadoMunicipios();

                }

             

                 getters and setters   

             

             

            }

             

            This is where I get de list

             

            public List<Municipio> listadoMunicipios() {

             

                    SessionFactory sf = HibernateUtil.getSessionFactory();

                    Session session = sf.openSession();

                    session.beginTransaction();

             

                    List<Municipio> municipios = session.createQuery("from Municipio").list();

             

                    session.close();

                    return municipios;

                 }

             

             

            Im declaring a Bean through annotations... I dont have a bean.xml in the WEB-INF folder..Looking through some tutorials, they dont mention any bean.xml file..

            • 3. Re: RichFaces 4.2.1 SEVERE ERROR with <rich:select> and <f:selectItems>
              Phanor Coll Newbie

              I've tried somethig else, when I changed the rich:select component from loading data from a DB to this

               

                                       <rich:select id="select" defaultLabel="Select Value..."

                                              value="#{crearSolicitud.var}">

                                              <f:selectItem itemValue="0" itemLabel="Banana" />

                                              <f:selectItem itemValue="1" itemLabel="Cranberry" />

                                              <f:selectItem itemValue="2" itemLabel="Blueberry" />

                                              <f:selectItem itemValue="3" itemLabel="Orange" />

                                              <f:selectItem itemValue="4" itemLabel="Strawberry" />

                                              <f:selectItem itemValue="4" itemLabel="Apple" />

                                          </rich:select>

               

              I still get the error... even when Im not populating the rich:selectItems component..

              • 4. Re: RichFaces 4.2.1 SEVERE ERROR with <rich:select> and <f:selectItems>
                Phanor Coll Newbie

                Apparently JSF stores the page component structure in HttpSession and If the page content is very large and the session has not been previously created, some response may have been written and the error above happens..

                 

                so the solution is to create the session before the Facelet (/JSF) page is printed.

                 

                An crude example could be like:

                 

                @PostConstruct
                void initialiseSession() {
                   
                FacesContext.getCurrentInstance().getExternalContext().getSession(true);
                }

                 

                creating the session before, preventes this error to happen Cannot create a session after the response has been committed