1 Reply Latest reply on Oct 30, 2003 10:11 AM by Adrian Brock

    Exception in an entity bean that calls another one

    brsmrk Newbie

      I wrote 2 entity bean BMP(called A and B) that map 2 tables in DB.
      I compiled, deployed and tested them. All worked fine.

      After that I added a method in the entity A (bean and interface):
      public void addB(String bvalue){
      try{
      Context initial = new InititalContext();
      Object ref = initial.lookup("b");
      BHome bhome = (BHome)PortableRemoteObject.narrow(ref,BHome.class);
      bhome.create(bvalue);
      }catch(Exception e){throw new EJBException(e.getMessage());}
      }

      Like above, I compiled, deployed and tested them. All continued worked fine, but each time I call the method "addB(bvalue)" by client...

      void main (...
      try{

      ...
      String avalue = "avalue";
      String bvalue = "bvalue";
      Object ref = initial.lookup("a");
      AHome ahome = (AHome)PortableRemoteObject.narrow(ref,AHome.class);
      ARemote aremote = ahome.create(avalue);
      aremote.addB(bvalue)
      }catch(Exception e){throw new EJBException(e.getMessage());}
      ...

      I obtain the following error:

      2003-10-29 12:28:15,515 ERROR [org.jboss.ejb.BeanLock] removing bean lock and it has tx set! QPL bean=A id=it.eng.pattern.pk.GruppoPK@35 tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=DELL0362//167, BranchQual=] synched=null timeout=5000 queue=[]
      2003-10-29 12:28:15,515 ERROR [org.jboss.ejb.plugins.LogInterceptor] RuntimeException:
      java.lang.IllegalStateException: removing bean lock and it has tx set!
      at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.removeRef(QueuedPessimisticEJBLock.java:430)
      at org.jboss.ejb.BeanLockManager.removeLockRef(BeanLockManager.java:107)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:106)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)

      ....

      Instead If i don't call that method, all continue to works fine.
      Help me to understand please.
      Ciao
      Mirko