4 Replies Latest reply on Jan 18, 2006 7:43 AM by Dimitris Andreadis

    Calling getEJBObject from SFSB instance

    Marek Gmyrek Newbie

      Hi,

      I have a question to calling getEJBObject from stateful bean instance.

      If I understand EJB 2.1 spec. correctly it is allowed to call getEJBObject from ejbCreate/Remove/Activate/Passivate. Calling this method is "disallowed in the session bean methods in which there is no session object identity established for the instance." and "disallowed if the session bean does not define a remote client view".

      I have SFSB with remote interface and I get IllegalStateException exception when calling getEJBObject from ejbActivate and ejbPassiavate. I use JBoss 4.0.3 SP1.

      Is this a spec. violation?

      Thanx,
      Marek.

        • 1. Re: Calling getEJBObject from SFSB instance
          Scott Stark Master

          Show the exception trace.

          • 2. Re: Calling getEJBObject from SFSB instance
            Marek Gmyrek Newbie

             

            "scott.stark@jboss.org" wrote:
            Show the exception trace.


            This is a very simple SFSB. I tested SFSB cache, so I put debug statements into ejb/Create/Activate/Passivate/Remove callbacks.

            It looks like AllowedOperationsAssociation assumes ejbPassivate is called on home ?

            Below the stack trace.

            14:02:41,796 TRACE [LRUEnterpriseContextCachePolicy] Aging out from cache bean Basketwith id = eia7t5bh-1i; cache size = 2
            14:02:41,796 TRACE [LRUEnterpriseContextCachePolicy] entryRemoved, entry=key: null, object: null, entry: 5a5622
            14:02:41,796 DEBUG [StatefulSessionFilePersistenceManager] Attempting to passivate; ctx=org.jboss.ejb.StatefulSessionEnterpriseContext@1cd9e66
            14:02:41,796 ERROR [AllowedOperationsAssociation] getEJBObject should not be access from this bean method: IN_EJB_HOME, allowed is [IN_EJB_ACTIVATE, IN_EJB_PASS
            IVATE, IN_EJB_REMOVE, IN_EJB_CREATE, IN_AFTER_BEGIN, IN_BEFORE_COMPLETION, IN_AFTER_COMPLETION, IN_BUSINESS_METHOD]
            java.lang.IllegalStateException: getEJBObject should not be access from this bean method: IN_EJB_HOME
             at org.jboss.ejb.AllowedOperationsAssociation.assertAllowedIn(AllowedOperationsAssociation.java:132)
             at org.jboss.ejb.StatefulSessionEnterpriseContext$StatefulSessionContextImpl.getEJBObject(StatefulSessionEnterpriseContext.java:182)
             at com.consol.courses.ejb.session.stateful.bean.BasketBean.p(BasketBean.java:82)
             at com.consol.courses.ejb.session.stateful.bean.BasketBean.ejbPassivate(BasketBean.java:60)
             at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:371)
             at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:93)
             at org.jboss.ejb.plugins.AbstractInstanceCache.tryToPassivate(AbstractInstanceCache.java:180)
             at org.jboss.ejb.plugins.AbstractInstanceCache.release(AbstractInstanceCache.java:221)
             at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy.ageOut(LRUEnterpriseContextCachePolicy.java:275)
             at org.jboss.util.LRUCachePolicy$LRUList.demote(LRUCachePolicy.java:346)
             at org.jboss.util.LRUCachePolicy.insert(LRUCachePolicy.java:162)
             at org.jboss.ejb.plugins.AbstractInstanceCache.insert(AbstractInstanceCache.java:138)
             at org.jboss.ejb.StatefulSessionContainer.createSession(StatefulSessionContainer.java:308)
             at org.jboss.ejb.StatefulSessionContainer.createHome(StatefulSessionContainer.java:323)
             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.invocation.Invocation.performCall(Invocation.java:345)
             at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invokeHome(StatefulSessionContainer.java:535)
             at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:130)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:180)
             at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invokeHome(StatefulSessionInstanceInterceptor.java:128)
             at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:41)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:110)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:146)
             at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
             at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:613)
             at org.jboss.ejb.Container.invoke(Container.java:894)
             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.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
             at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
             at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
             at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:179)
             at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:165)
             at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
             at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
             at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:169)
             at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
             at $Proxy93.create(Unknown Source)
             at com.consol.courses.servlet.BasketServlet.actionCreate(BasketServlet.java:143)
             at com.consol.courses.servlet.BasketServlet.processRequest(BasketServlet.java:60)
             at com.consol.courses.servlet.BasketServlet.doGet(BasketServlet.java:206)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
             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: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.valves.FastCommonAccessLogValve.invoke(FastCommonAccessLogValve.java:481)
             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)
            14:02:41,826 INFO [STDOUT] BasketBean:: EJB life-cycle: passivate [com.consol.courses.ejb.session.stateful.bean.BasketBean:ee7e66:1:3::1ac9683]
            


            Btw. would you plese explain why with SFSB cache when calling a business method on passivated bean a new bean instance is created, which is actually not used during method invocation.

            Thanx,
            Marek.