1 Reply Latest reply on Jan 29, 2002 12:24 PM by mescalito

    Unexpected switching of JNDI environment in ejbStore

    mescalito

      We've moved from JBoss-2.4.3+Tomcat-3.2.3 to JBoss-2.4.4_Tomcat-4.0.1 recently and noticed some strange behaviour while processing the transaction:
      We're doing 2 calls to the entity bean which uses its JNDI environment variables and makes calls to other beans. And getting errors in the subsequent ejbStore call while trying to access JNDI environment. We've made some investigations and have found that the problem occurs only while running org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction (if ejbStore is called in any other way all is working properly), and it seems that ejbStore uses the environment of _other_ beans (we've printed out the bean's environment to the console in the beginning of ejbStore and have got the environment entries from the _other_ bean which was involved in the transaction) It seems as if container calls ejbStore for all the beans involved in the transaction, with switching the environment BUT with calling ejbStore of only _one_ bean several times. Or just not switching the environment.

      [INFO,Default] 2002.01.29 10:22:24 station_dev:JBoss::User::TRACE:Entering setEntityContext(EntityContext)::
      [INFO,Default] 2002.01.29 10:22:24 station_dev:JBoss:station:User::TRACE:Entering ejbFindByPrimaryKey(UserPK)::
      [INFO,Default] 2002.01.29 10:22:24 station_dev:JBoss::User::TRACE:Entering setEntityContext(EntityContext)::
      [INFO,Default] 2002.01.29 10:22:24 station_dev:JBoss::User:qqq(2):TRACE:Entering ejbActivate()::
      [INFO,Default] 2002.01.29 10:22:24 station_dev:JBoss:station:User:qqq(2):TRACE:Entering ejbLoad()::
      [INFO,Default] 2002.01.29 10:22:24 station_dev:JBoss:station:User:qqq(2):TRACE:Entering updateUser(UserDVO)::
      [INFO,Default] 2002.01.29 10:22:24 station_dev:JBoss:station:User:qqq(2):TRACE:Entering updateRoleList(Collection)::
      /**** this is the entry from the LogManager bean's env instead of expected User bean's env ***/
      [INFO,Default] log: org.jnp.interfaces.NamingContext:org.jnp.interfaces.NamingContext@4e0e18 [INFO,Default] 2002.01.29 10:22:24 station_dev:JBoss:station:User:qqq(2):TRACE:Entering ejbStore()::
      [ERROR,LogManager] TRANSACTION ROLLBACK EXCEPTION:
      javax.transaction.TransactionRolledbackException: null
      Embedded Exception
      Error while retrieving environment variable: user not bound; nested exception is:
      javax.ejb.EJBException: null
      Embedded Exception
      Error while retrieving environment variable: user not bound
      javax.ejb.EJBException: null
      Embedded Exception
      Error while retrieving environment variable: user not bound
      at org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction(EntityContainer.java:2
      30)
      at org.jboss.ejb.EntityContainer.find(EntityContainer.java:577)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:859)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationIn
      terceptor.java:234)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java
      :147)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:97)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:142)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:102)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:103)
      at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:421)
      at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.ja
      va:456)
      at org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invokeHome(HomeProxy.java:237)
      at org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:182)
      at $Proxy93.findByPrimaryKey(Unknown Source)
      at com.blah.appadmin.log.AbstractLoggerImpl.getLoggingMask(AbstractLoggerImpl.java:342)

      at com.blah.appadmin.log.AbstractLoggerImpl.isTraceLoggable(AbstractLoggerImpl.java:269
      )
      at com.blah.appadmin.role.ejb.RoleEB.setEntityContext(RoleEB.java:156)
      at org.jboss.ejb.EntityEnterpriseContext.(EntityEnterpriseContext.java:78)
      at org.jboss.ejb.plugins.EntityInstancePool.create(EntityInstancePool.java:86)
      at org.jboss.ejb.plugins.AbstractInstancePool.add(AbstractInstancePool.java:153)
      at org.jboss.ejb.plugins.AbstractInstancePool.internalGet(AbstractInstancePool.java:216)
      at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:191)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java
      :136)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:97)
      ................
      javax.ejb.EJBException: Error while retrieving environment variable: user not bound
      at com.blah.appadmin.user.ejb.UserEB.getRoleNotification(UserEB.java:736)
      at com.blah.appadmin.user.ejb.UserEB.ejbStore(UserEB.java:207)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenceManager.java:361)
      at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:253)
      at org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction(EntityContainer.java:2
      24)
      ...............
      /**** this is the entry from the Role bean's env instead of expected User bean's env ***/
      [INFO,Default] role: org.jnp.interfaces.NamingContext:org.jnp.interfaces.NamingContext@7a8ba4
      [INFO,Default] 2002.01.29 10:22:24 station_dev:JBoss:station:User:qqq(2):TRACE:Entering ejb
      Store()::
      [ERROR,Role] TRANSACTION ROLLBACK EXCEPTION:
      javax.transaction.TransactionRolledbackException: null
      Embedded Exception
      Error while retrieving environment variable: user not bound; nested exception is:
      javax.ejb.EJBException: null
      Embedded Exception
      Error while retrieving environment variable: user not bound
      javax.ejb.EJBException: null
      Embedded Exception
      Error while retrieving environment variable: user not bound
      at org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction(EntityContainer.java:2
      30)
      at org.jboss.ejb.EntityContainer.find(EntityContainer.java:577)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:859)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationIn
      terceptor.java:234)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java
      :147)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:97)
      ...........
      (the complete stack trace is too long)
      Three beans were involved in the transaction: User, Role and LogManager (the last two ones were called by the User bean)
      Could somebody tell me what's going on?
      Thanks.

        • 1. Re: Unexpected switching of JNDI environment in ejbStore
          mescalito

          Further investigation:
          It seems that JBoss 2.4.4 doesn't allow to invoke any finders and remove() methods for any beans inside of ejbStore() (it's possible in JBoss 2.4.3). To be exact, it allows it, but it may cause an infinite loop (because the new implementation of internal finder support methods forces to synchronize all the beans involved in transaction (including the invoker bean), so ejbStore() is called...)
          Am I right? If it is so, I just don't understand the reason of such change in implementation, because EJB 2.0 spec tells that ALL external bean invocations are allowed inside ejbLoad/ejbStore.
          Thanks in advance.