3 Replies Latest reply on Aug 3, 2007 9:18 PM by Paul Pantages

    Can't find Stateful Bean...

    Paul Pantages Novice

      Seam 1.2.1 GA
      Tomahawk - 1.1.6

      Hello Seamers,

      Wrt my stateful bean error, I am still struggling with this.
      One of my scenarios follows:

      - I have an SFSB, CONVERSATION scope, containing a @DataModel
      @Name("serviceMgmt")

      - The Datamodel is used to render a data table using t:dataTable

      - I have an ajax poll that checks the table bean for updates every 4s

      - The table @Create method is annotated with @Begin so the table bean maintained in an LRC.

      - The table rows have an s:link rendered which is used to edit the
      objects displayed in the table.

      - The editor, another SFSB, is launched by an action annoated with
      @Begin(nested=true), so the editing is done in a nested LRC.
      @Name("sserviceEditor")

      - The editor injects another SFSB (a table),with @In(create=true)
      This bean should not exist inthe parent conversation.
      @Name("serviceEndPointMgmt")
      It is a reference to serviceEndPointMgmt causes the error.


      Normally, evertyhing works correctly. The workspace switcher shows the
      parent and nested conversation as I would expect.

      However, if I leave the page alone for 15 minutes, touching nothing,
      and then try the edit link, I get the "stateful bean error".

      The error is due to a reference to the component "serviceEndPointMgmt"
      (see code & logs below)

      The ajax poller keeps the conversation alive, and the workspace
      switcher confirms that the parent conversation is still active before
      the attempted edit.


      The table backing bean is annotated like so:

      @Stateful
      @Scope(CONVERSATION)
      @Synchronized
      @Name("serviceMgmt")
      @LoggedIn
      public class ServiceTableBean extends GenericTableBean implements ServiceTableLocal
      {
       ....
      }
      


      The s:links in the table rows are defined like this:
      <s:link value="#{row.name}"
       title="Edit this service definition."
       action="#{sserviceEditor.edit(row.id)" >
       <f:param name="rowId" value="#{row.id}"/>
      </s:link>
      



      The editor component:
      @Stateful
      @Scope(CONVERSATION)
      @LoggedIn
      @Synchronized
      @Conversational
      @Name("sserviceEditor")
      public class ServiceEditBean extends GenericEditorBean implements ServiceEditLocal {
      
      @In(create=true)
      @Out
      ServiceEndPointTableLocal serviceEndPointMgmt;
      
      ....
      
      @Begin(nested=true)
      public String edit(String id)
      {
       ....
       ....
      
       // The nested conversation has not started yet...
      
       // Here we get a "can't find stateful bean error" ... sometimes.
       serviceEndPointMgmt.setServiceProxy( this.serviceEntry );
      
      }
      


      SEAM Logs:

      I turned up the Seam logging level. I can see that the offending bean
      seems to be available, but then the reference to it somehow triggers
      its removal.

      I do not really understand why serviceEndPointMgmt bean is initially
      found in the conversation context (maybe because create=true), or why
      would it be subsequently removed after/by the RootInterceptor?

      2007-08-02 15:33:04,530 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.Component
      trying to inject with hierarchical context search: serviceEndPointMgmt
      
      2007-08-02 15:33:04,530 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.contexts.Contexts
      found in conversation context: serviceEndPointMgmt
      ....
      ....
      
      2007-08-02 15:33:04,531 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.core.Events
      Processing event:org.jboss.seam.preSetVariable.serviceEndPointMgmt
      ....
      ....
      
      2007-08-02 15:33:04,531 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.core.Events
      Processing event:org.jboss.seam.postSetVariable.serviceEndPointMgmt
      ....
      ....
      2007-08-02 15:33:04,533 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.Component
      trying to inject with hierarchical context search: serviceEndPointMgmt
      
      2007-08-02 15:33:04,533 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.contexts.Contexts
      found in conversation context: serviceEndPointMgmt
      ....
      ....
      2007-08-02 15:33:04,689 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.intercept.RootInterceptor
      intercepted: serviceEndPointMgmt.setServiceProxy
      ...
      ...
      2007-08-02 15:33:04,690 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.core.Events
      Processing event:org.jboss.seam.preRemoveVariable.serviceEndPointMgmt
      ....
      ....
      2007-08-02 15:33:04,690 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.core.Events
      Processing event:org.jboss.seam.postRemoveVariable.serviceEndPointMgmt
      
      2007-08-02 15:33:04,690 DEBUG [http-0.0.0.0-8080-9] org.jboss.seam.interceptors.RemoveInterceptor
      Stateful component was removed: serviceEndPointMgmt
      ....
      ....
      2007-08-02 15:33:04,690 ERROR [http-0.0.0.0-8080-9] centina.sa.client.service.ServiceEditBean
      Could not find Stateful bean: 4su05k-8qg8ht-f4vo5u8v-1-f4voruaw-2o
      
      javax.ejb.EJBNoSuchObjectException: Could not find Stateful bean: 4su05k-8qg8ht-f4vo5u8v-1-f4voruaw-2o
       at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:268)
       at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:61)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:203)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       at $Proxy256.setServiceProxy(Unknown Source)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
       at org.javassist.tmp.java.lang.Object_$$_javassist_36.setServiceProxy(Object_$$_javassist_36.java)
       at centina.sa.client.service.ServiceEditBean.initServiceEndPoints(ServiceEditBean.java:475)
       at centina.sa.client.service.ServiceEditBean.edit(ServiceEditBean.java:161)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:37)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:54)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at centina.sa.client.session.LoggedInInterceptor.checkLoggedIn(LoggedInInterceptor.java:97)
       at sun.reflect.GeneratedMethodAccessor177.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:178)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:73)
       at org.jboss.seam.interceptors.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:37)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.ConversationalInterceptor.aroundInvoke(ConversationalInterceptor.java:89)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
       at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:203)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       at $Proxy255.edit(Unknown Source)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
       at org.javassist.tmp.java.lang.Object_$$_javassist_35.edit(Object_$$_javassist_35.java)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
       at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
       at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
       at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:148)
       at org.jboss.seam.core.Pages.callAction(Pages.java:499)
       at org.jboss.seam.core.Pages.enterPage(Pages.java:282)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.enterPage(AbstractSeamPhaseListener.java:276)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:214)
       at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:56)
       at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:70)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:373)
       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.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
       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: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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
       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)
      
      
      



        • 1. Re: Can't find Stateful Bean...
          Pete Muir Master

          The EJB3 stateful object timesout, probably because it hasn't been accessed in a while. Perhaps you need to touch it regularly.

          • 2. Re: Can't find Stateful Bean...
            Paul Pantages Novice

            Hello Peter, thank you for your response.

            Unfortunately, Seam component serviceEndPointMgmt does not exist in the parent conversation prior to invoking the editor (which in turn causes the exception). I can verify the absence of this object with the seam debugger. It is supposed to be created only when the editor is launched.

            Thus, I don't quite understand the log message about finding it in the conversation; I assumed that this is just a side-effect of using @In(create=true). I will stick some traces in the ctor and @Create method and see if I can find anything.

            So, the upshot is, I don't quite understand how I can periodically touch it. Normally, this would be easy to do, as my page has an ajax poll every 4s...

            Could I avoid the problem by declaring the injected object transient? I have never tried this on a seam component.

            Thanks PdP

            • 3. Re: Can't find Stateful Bean...
              Paul Pantages Novice

              I think I have finally sorted this out.

              This seems to be due to my use of the following in my editor's "apply" method:

              ...
              Conversation.instance().end();
              Conversation.instance().pop();
              
              // We are in the parent conversation now ...
              serviceMgmt.refresh();
              
              serviceEndPointMgmt.refresh(); // This is the bug
              
              ...
              


              I used this instead of the normal @End as I wanted to update the
              serviceMgmt in the parent's conversation to reflect the edit.
              Since componet serviceMgmt is "read-only" in the nested conversation, I have to get back to the parent to update it.

              The reference to serviceEndPointMgmt must have caused a re-instantiation of this
              component, in the parent conversation, since I am using @In(create=true)
              This reference is just a bug; it was completely unnecessary.

              This is how the parent conversation obtained a reference to the ID of a cached serviceEndPointMgmt object. It also explains what I saw in the logs.

              Since the parent's conversation's beans don't touch serviceEndPointMgmt, it timed out of the cache.

              The next edit session (a new nested conversation) inherited the reference from the parent, tried to get the bean from the cache and caused the stateful bean error.

              Once I removed the reference, my application behaved properly.

              It looks like Peter was right about the root cause of this....

              Can anyone confirm/deny this explanation?

              Hopefully this will help someone, somewhere...

              PdP