10 Replies Latest reply on Sep 21, 2007 9:47 AM by lowecg2004

    @Unwrap from SFSB and session timeout issue

    jazir1979

      Hi folks,

      I have a "UserManager" SFSB Seam component with session scope that uses the @Unwrap annotation to unwrap a User entity bean. I believe this is the "manager component" pattern described in the Seam reference guide.

      I am doing it this way because I don't want my User entity to be a seam component in its own right, and I want clustering/state replication to occur on my UserManager SFSB that has the User as an instance variable.

      This all works really well until a session timeout occurs - Seam tries to find a destroy() method on the User entity bean instead of the UserManager SFSB!!

      Here is the stacktrace:

      java.lang.IllegalArgumentException: method not found: destroy for component: user (check that it is declared on the session bean business interface)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1809)
       at org.jboss.seam.Component.callDestroyMethod(Component.java:1747)
       at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:189)
       at org.jboss.seam.contexts.Lifecycle.endSession(Lifecycle.java:230)
       at org.jboss.seam.servlet.SeamListener.sessionDestroyed(SeamListener.java:45)
       at org.apache.catalina.session.StandardSession.expire(StandardSession.java:687)
       at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:579)
       at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:678)
       at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:663)
       at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1284)
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1569)
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1578)
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1578)
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1558)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.NoSuchMethodException: entity.User.destroy()
       at java.lang.Class.getMethod(Class.java:1581)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1788)
       ... 14 more
      


      Is this behaviour expected?

      cheers,
      Daniel.


        • 1. Re: @Unwrap from SFSB and session timeout issue

          No, I wouldn't think it should work like this. Can you open a JIRA case, perhaps with some supporting code that illustrates this in case it's not a completely obvious bug.

          • 2. Re: @Unwrap from SFSB and session timeout issue
            jazir1979

            Created JIRA issue: http://jira.jboss.org/jira/browse/JBSEAM-636

            I'll upload some sample code to demonstrate it very soon. If I get a chance I may also look at the source and see if I can identify a reasonable fix.

            thanks,
            Daniel.

            • 3. Re: @Unwrap from SFSB and session timeout issue
              tom_goring

              Hi,

              Using seam 1.1.6.GA I get the same issue.
              According to the JIRA it is set to "Cannot Reproduce Bug"



              3:16:04,609 WARN [Contexts] Could not destroy component: user
              java.lang.IllegalArgumentException: method not found: destroy for component: user (check that it is declared on the session bean business interface)
               at org.jboss.seam.Component.callComponentMethod(Component.java:1853)
               at org.jboss.seam.Component.callDestroyMethod(Component.java:1791)
               at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:230)
               at org.jboss.seam.contexts.Lifecycle.flushAndDestroyContexts(Lifecycle.java:396)
               at org.jboss.seam.contexts.Lifecycle.endRequest(Lifecycle.java:302)
               at org.jboss.seam.jsf.AbstractSeamPhaseListener.afterRender(AbstractSeamPhaseListener.java:224)
               at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:116)
               at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersAfter(PhaseListenerManager.java:89)
               at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:391)
               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
               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.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
               at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
               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:869)
               at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
               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)
              


              Here is my managed component:

              @Stateful
              @Name(UserComponentNames.User)
              @Scope(ScopeType.CONVERSATION)
              public class UserComponentManagerBean implements UserComponentManager {
              
               @In(value=UserComponentNames.UserId)
               private Long userId = null;
              
               @EJB
               private UserManagerLocal userManager;
              
               @Unwrap
               public User getUser() {
               if ( userId!=null ) {
               return userManager.getUser(userId);
               }
               return null;
               }
              
               @Destroy @Remove
               public void destroy() {
              
               }
              }
              



              My user is just an EJB3 entity bean:
              @Entity(name="user")
              @Table(name="user")
              public class User extends BaseEntity {
              



              • 4. Re: @Unwrap from SFSB and session timeout issue
                lowecg2004

                Is there another bean somewhere with the name "user"?

                • 5. Re: @Unwrap from SFSB and session timeout issue
                  tom_goring

                  Hi,

                  Thanks for the advise but no it's not the issue.
                  I renamed the component just to check ("userXx") stack below.

                  Ideas ? Does anyone have SFSB acting as a manager using @Unwrap to a entity bean ?


                  17:41:51,187 WARN [Contexts] Could not destroy component: userXx
                  java.lang.IllegalArgumentException: method not found: destroy for component: userXx (check that it is declared on the session bean business interface)
                   at org.jboss.seam.Component.callComponentMethod(Component.java:1853)
                   at org.jboss.seam.Component.callDestroyMethod(Component.java:1791)
                   at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:230)
                   at org.jboss.seam.contexts.Lifecycle.flushAndDestroyContexts(Lifecycle.java:396)
                   at org.jboss.seam.contexts.Lifecycle.endRequest(Lifecycle.java:302)
                  




                  • 6. Re: @Unwrap from SFSB and session timeout issue
                    lowecg2004

                    What's the value of UserComponentNames.User?

                    Does the SFSB have destroy() defined on the @Local interface UserComponentManager?

                    • 7. Re: @Unwrap from SFSB and session timeout issue
                      tom_goring

                       

                      Does the SFSB have destroy() defined on the @Local interface UserComponentManager?


                      Nope ! All working as expected now ... Thanks for you help !

                      • 8. Re: @Unwrap from SFSB and session timeout issue
                        lowecg2004

                        Glad to be of service!

                        Chris.

                        • 9. Re: @Unwrap from SFSB and session timeout issue
                          hannes_ifs

                           

                          "tom_goring" wrote:
                          Does the SFSB have destroy() defined on the @Local interface UserComponentManager?


                          Nope ! All working as expected now ... Thanks for you help !


                          Hi all,

                          I am using Seam 1.2.1.GA and JBoss 4.0.5 and ran into the same problem recently. Is it really absolutely necessary to add the destroy method to the @Local interface? I am asking because in quite a lot of Seam examples you don't see that.

                          Thanks for your help



                          • 10. Re: @Unwrap from SFSB and session timeout issue
                            lowecg2004

                            Hi,

                            In short, I believe the answer is "Yes" - if your beans are defined as SFSB then methods are only available if exposed via the corresponding @Local or @Remote interfaces. Some of the examples use SFSBs which have the @Stateful annotation while other examples use simple POJOs where no local interface required - as a minimum, only @Name is needed to interact with the bean in the Seam environment. Maybe the examples you have seen use the latter?

                            I hope that helps. If this still doesn't match what you're seeing then can you point me to the example you're looking at?

                            Regards,

                            Chris.