9 Replies Latest reply on Feb 8, 2006 9:16 AM by js8523

    Seam and Servlet

    js8523 Novice

      Hi Folks

      I am currently writing a servelt but I wish to access seam components (in particular a Stateful session bean (working as a conversation backing bean) from the servlet.

      This is for generating a pdf form from the conversationally scoped information.

      I have tried

      Component.getInstance("createReservationWizard", false);


      but all the scopes are not active in the servlet context and it returns null (even though it does exist). I am assuming that the servlet has its own session context, so I can't get in that way.

      If anyone has any tips or experiences I would really appreciate it.

      Many thanks,

      James


        • 1. Re: Seam and Servlet
          Gavin King Master

          Use SeamServletFilter.

          • 2. Re: Seam and Servlet
            js8523 Novice

            I am trying to use the SeamServletFilter and everything is working in the correct manner except when I try to pass conversationId through to it by doing this.

            http://localhost:8080/Sales/servlet/reservationForm.pdf?conversationId=1
            


            I get a class cast exception converting it to a String? When the org.jboss.seam.core.manager is trying to fetch the parameter from the hashset, however when I try to pull the value myself in the servlet I can get it fine???

            I presume that passing the conversationId is the correct way of getting the seam servlet filter to pick up the current conversation.

            Thanks,

            James



            • 3. Re: Seam and Servlet
              Gavin King Master

              Yes, that is the correct way. Hmmm. Please show me the stack trace.

              • 4. Re: Seam and Servlet
                js8523 Novice

                 

                17:06:04,189 ERROR [SeamExceptionFilter] uncaught exception handled by Seam
                java.lang.ClassCastException: [Ljava.lang.String;
                 at org.jboss.seam.core.Manager.restoreConversation(Manager.java:386)
                 at org.jboss.seam.servlet.SeamServletFilter.doFilter(SeamServletFilter.java:42)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:44)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                 at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
                 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                 at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                 at java.lang.Thread.run(Thread.java:595)
                17:06:04,221 ERROR [[PDFReservationForm]] Servlet.service() for servlet PDFReservationForm threw exception
                java.lang.ClassCastException: [Ljava.lang.String;
                 at org.jboss.seam.core.Manager.restoreConversation(Manager.java:386)
                 at org.jboss.seam.servlet.SeamServletFilter.doFilter(SeamServletFilter.java:42)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:44)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                 at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
                 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                 at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                 at java.lang.Thread.run(Thread.java:595)


                Used using this url.


                http://localhost:8080/Sales/servlet/ReservationForm.pdf?conversationId=1


                I am using the latest Seam that will work on Jboss 4.0.3SP1 (TAGGED).

                Thanks,

                James

                • 5. Re: Seam and Servlet
                  Gavin King Master

                  Thanks, silly bug.

                  I will fix now.

                  • 6. Re: Seam and Servlet
                    Gavin King Master

                    It's fixed in CVS. Please let me know how you go...

                    • 7. Re: Seam and Servlet
                      js8523 Novice

                      Hi Gavin

                      I shall have to wait until Jboss 4.0.4RC1 is released as I am running on the tagged version for jboss 4.0.3SP1 currently.

                      I will let you know when I move up to the HEAD version of seam.

                      Thanks again,

                      James

                      • 8. Re: Seam and Servlet
                        Gavin King Master

                        You will probably have success if you install the latest rev of EJB3 in 4.0.3sp1:

                        http://jboss.com/products/list/downloads#ejb3

                        And then run Seam CVS or nightly build.

                        I have not actually tried this myself, but I understand from Thomas that it is working.

                        • 9. Re: Seam and Servlet
                          js8523 Novice

                          Hi Gavin

                          The Seam Servlet fix you wrote worked, and I am know back on the CVS version (I can now start using all of the new goodies), thanks.

                          Jboss 4.0.3SP1 and the latest EJB3 implementation is working for me too.

                          Thanks again,

                          James

                          P.S For those that aren't following the EJB3 forum they have released a binary build of Jboss 4.0.4RC1 through sourceforge see the announcement forum for the location.