1 Reply Latest reply on Mar 7, 2004 5:48 AM by Konstantin Sobolev

    bug when ejbStore calls finder

    Konstantin Sobolev Newbie

      Hi all,

      There is a bug (probably) in new JBoss, briefly it doesn't expect that
      ejbStore will call finder method and doesn't protect list of entities
      changed in transaction from reentrant calls
      (see GlobalTXEntityMap.synchronizeEntities).

      Real example:
      ActionBean, BMP entity bean, ejbStore() method:

      ActionDataHolderBrokerLocal holderBroker = getActionDataHolderBrokerLocalHome().create();
      holderBroker.updateActionData(new Long(pk.getId()), data);//line 233
      


      ActionDataHolderBrokerBean:
      public void updateActionData(Long actionPK, ActionData actionData) throws ActionDataHolderException {
       findActionDataHolder(actionPK).setActionData(actionData);//72
      }
      ...........
      private ActionDataHolderLocalBI findActionDataHolder(Long actionPK) throws ActionDataHolderException {
       ActionDataHolderLocalBI holder;
       try {
       holder = findUpdateDataHolder(actionPK); //line 91
       if (holder == null)
       holder = findRulesEmailDataHolder(actionPK);
       if (holder == null)
       holder = findGenericActionlDataHolder(actionPK);
       if (holder == null)
       throw new ActionDataHolderException("Can't find ActionData holder by actionPK=" + actionPK);
       } catch (FinderException e) {
       String msg = "Error finding ActionData holder: " + e;
       log.error(msg, e);
       throw new ActionDataHolderException(msg);
       }
       return holder;
      }
      ...........
      private ActionDataHolderLocalBI findUpdateDataHolder(Long actionPK) throws FinderException {
       try {
       return getUpdateDataHolderLocalHome().findByPrimaryKey(actionPK); //line 108
       } catch (ObjectNotFoundException e) {
       return null;
       }
      }
      


      now stacktrace that clearly shows looping error
       at $Proxy976.updateActionData(Unknown Source)
       at com.supportwizard.actions2.ejb.ActionBean.ejbStore(ActionBean.java:233)
       at com.supportwizard.actions2.ejb.ActionBMP.ejbStore(ActionBMP.java:60)
       at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenceManager.java:454)
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity(CachedConnectionInterceptor.java:387)
       at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:714)
       at org.jboss.ejb.GlobalTxEntityMap.synchronizeEntities(GlobalTxEntityMap.java:149)
       at org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction(EntityContainer.java:119)
       at org.jboss.ejb.EntityContainer.findLocal(EntityContainer.java:607)
       at sun.reflect.GeneratedMethodAccessor285.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1043)
       at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
       at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:197)
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:214)
       at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
       at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:89)
       at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
       at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88)
       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:297)
       at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:98)
       at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92)
       at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
       at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:483)
       at org.jboss.ejb.Container.invoke(Container.java:720)
       at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:293)
       at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
       at $Proxy928.findByPrimaryKey(Unknown Source)
       at com.supportwizard.actions2.persistence.ejb.ActionDataHolderBrokerBean.findUpdateDataHolder(ActionDataHolderBrokerBean.java:108)
       at com.supportwizard.actions2.persistence.ejb.ActionDataHolderBrokerBean.findActionDataHolder(ActionDataHolderBrokerBean.java:91)
       at com.supportwizard.actions2.persistence.ejb.ActionDataHolderBrokerBean.updateActionData(ActionDataHolderBrokerBean.java:72)
       at sun.reflect.GeneratedMethodAccessor313.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
       at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
       at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
       at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
       at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
       at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
       at org.jboss.ejb.Container.invoke(Container.java:700)
       at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:375)
       at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:83)
       at $Proxy976.updateActionData(Unknown Source)
       at com.supportwizard.actions2.ejb.ActionBean.ejbStore(ActionBean.java:233)
       at com.supportwizard.actions2.ejb.ActionBMP.ejbStore(ActionBMP.java:60)
      

      and so on.

      Proposed patch for GlobalTXEntityMap.java, from 3.2.3:
      105a106
      > entitiesFifoMap.set(tx,null);
      116a118
      > entitiesSetMap.set(tx,null);
      


      thanks