4 Replies Latest reply on Oct 17, 2007 9:33 PM by shane.bryzak

    GWT Remoting Example is not working

    soshah

      OS: Linux Fedora Core 6
      JVM: java version "1.5.0_11"
      JBoss AS: 4.2.1.GA
      Seam: 2.0.0.CR2

      When trying to run the GWT/Remoting example included under examples/remoting/gwt, I am getting the following stack trace:

      Note: the example is deployed using 'ant deploy' and the following URL:
      http://localhost:8080/seam-gwt

      11:02:10,190 INFO [Server] JBoss (MX MicroKernel) [4.2.1.GA (build: SVNTag=JBoss_4_2_1_GA date=200707131605)] Started in 28s:157ms
      11:02:19,279 ERROR [[default]] Servlet.service() for servlet default threw exception
      java.lang.IllegalStateException: Cannot create a session after the response has been committed
       at org.apache.catalina.connector.Request.doGetSession(Request.java:2284)
       at org.apache.catalina.connector.Request.getSession(Request.java:2066)
       at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
       at org.jboss.seam.servlet.ServletRequestSessionMap.put(ServletRequestSessionMap.java:87)
       at org.jboss.seam.servlet.ServletRequestSessionMap.put(ServletRequestSessionMap.java:25)
       at org.jboss.seam.contexts.BasicContext.set(BasicContext.java:80)
       at org.jboss.seam.Component.newInstance(Component.java:1980)
       at org.jboss.seam.Component.getInstance(Component.java:1878)
       at org.jboss.seam.Component.getInstance(Component.java:1857)
       at org.jboss.seam.Component.getInstance(Component.java:1834)
       at org.jboss.seam.web.Session.getInstance(Session.java:122)
       at org.jboss.seam.contexts.Contexts.flushAndDestroyContexts(Contexts.java:375)
       at org.jboss.seam.contexts.Lifecycle.endRequest(Lifecycle.java:132)
       at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:65)
       at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       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:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      


      Thanks


        • 1. Re: GWT Remoting Example is not working
          shane.bryzak

          This bug was just fixed recently.

          • 2. Re: GWT Remoting Example is not working
            soshah

            Is the bug fix related to this report?

            http://jira.jboss.com/jira/browse/JBSEAM-1102

            If so, looks like the bug fix should be included under 2.0.0CR2 which is what I am using,

            btw- I am using the released package from the JBoss.org site, without any code changes on my part. Just following the readme instructions and deploying the example

            Do you think I should try the trunk to see if the bug fix is working there?

            Thanks

            • 3. Re: GWT Remoting Example is not working
              soshah

              Shane-

              This may very well be a hack job based on my novice understanding of Seam contexts. But after debugging here is what I did and it seems to have fixed the remote GWT example. Like I said, I am not sure what the side effects of this change could be.

              Inside class org.jboss.seam.servlet.ContextualHttpServletRequest made the following change

              public void run() throws ServletException, IOException
               {
               log.debug("beginning request");
               ServletLifecycle.beginRequest(request);
               ServletContexts.instance().setRequest(request);
               restoreConversationId();
               Manager.instance().restoreConversation();
               ServletLifecycle.resumeConversation(request);
               handleConversationPropagation();
               try
               {
               //This code was added, because apparently it kept throwing
               //IllegalStateException if the response has been committed
               if(request.getSession(false) == null)
               {
               request.getSession(true);
               }
              
               process();
               //TODO: conversation timeout
               Manager.instance().endRequest( new ServletRequestSessionMap(request) );
               ServletLifecycle.endRequest(request);
               }
               catch (IOException ioe)
               {
               Lifecycle.endRequest();
               log.error("ended request due to exception", ioe);
               throw ioe;
               }
               catch (ServletException se)
               {
               Lifecycle.endRequest();
               log.error("ended request due to exception", se);
               throw se;
               }
               catch (Exception e)
               {
               Lifecycle.endRequest();
               log.error("ended request due to exception", e);
               throw new ServletException(e);
               }
               finally
               {
               log.debug("ended request");
               }
               }
              


              and inside the examples/remoting/gwt/resources/WEB-INF/web.xml I had to modify the filter mapping as follows:

              <filter-mapping>
               <filter-name>Context Filter</filter-name>
               <url-pattern>*.html</url-pattern>
               <exclude-pattern>/seam/resource/*</exclude-pattern>
               </filter-mapping>
              


              Thanks

              • 4. Re: GWT Remoting Example is not working
                shane.bryzak

                I've moved this change from GWTService to ContextualHttpRequest, as we discussed Sohil.