3 Replies Latest reply on Aug 16, 2002 1:20 AM by Carmen Bastiaans

    IllegalStateException: "removing bean lock and it has tx set

    Bartee Natarajan Newbie

      Hi,
      We are using JBoss2.4.3 on Solaris/Windows2000 and JDK1.3.1.

      In our code we are accessing an entity bean from within a statelss session bean using local ejb references conforming to EJB 1.1 spec. The deployment descriptor block for our entity bean is shown below.


      <ejb-name>com.artesia.property.enumMap.EnumMapHome</ejb-name>
      com.artesia.property.enumMap.EnumMapHome
      com.artesia.property.enumMap.EnumMapRemote
      <ejb-class>com.artesia.property.enumMap.EnumMapEJB</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>com.artesia.property.enumMap.EnumMapPK</prim-key-class>
      False


      We don't specify any transaction attributes for this entity bean methods. Can you tell me what the default attribute is?

      In any case, after running the server for a little while we encounter a stack trace as shown below:

      [EnumMapHome] TRANSACTION ROLLBACK EXCEPTION:removing bean lock and it has tx set!; nested exception i
      s:
      java.lang.IllegalStateException: removing bean lock and it has tx set!
      [EnumMapHome] java.lang.IllegalStateException: removing bean lock and it has tx set!
      [EnumMapHome] at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.removeRef(QueuedPessimisticEJBL
      ock.java:447)
      [EnumMapHome] at org.jboss.ejb.BeanLockManager.removeLockRef(BeanLockManager.java:79)
      [EnumMapHome] at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:153)
      [EnumMapHome] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
      [EnumMapHome] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:30
      7)
      [EnumMapHome] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
      [EnumMapHome] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
      [EnumMapHome] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
      [EnumMapHome] at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:427)
      [EnumMapHome] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.
      java:489)
      [EnumMapHome] at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.jav
      a:335)
      [EnumMapHome] at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:133)
      [EnumMapHome] at $Proxy35.getCodeToNameMap(Unknown Source)
      [EnumMapHome] at com.artesia.property.db.PropertyContainer.convertToProperties(PropertyContainer.jav
      a:393)
      [EnumMapHome] at com.artesia.property.db.PropertyContainer.getProperties(PropertyContainer.java:210)
      [EnumMapHome] at com.artesia.property.db.d.a(d.java)
      [EnumMapHome] at com.artesia.property.db.a.writeToDb(a.java)
      [EnumMapHome] at com.artesia.property.db.ValueEditorHandler.populateProperties(ValueEditorHandler.ja
      va)
      [EnumMapHome] at com.artesia.property.manager.PropertyManagerHelper.addProperties(PropertyManagerHel
      per.java)
      [EnumMapHome] at com.artesia.property.manager.PropertyManagerEJB.addProperties(PropertyManagerEJB.ja
      va)


      As you can see from the stack trace, PropertyManagerEJB is our stateless session bean. It is configured to have Bean-managed transactions and we do not start a transaction programmatically. When it attempts to invoke a method on the entity bean after locating it we encounter this stack trace. We found similar issues in your forum an d one of the answers implied that our PK class might be at fault in its equals and hashcode methods. We double-checked it and it seems to be OK. We are confused and any help on this issue would be appreciated..

      -bharathi
      Principal Software Engr.
      Artesia Technologies.

        • 1. Re: IllegalStateException: "removing bean lock and it has tx
          Peter Levart Newbie

          I had the same problem (although with JBoss 3.0 beta2). I just managed to fix it. Are you by any chance using Oracle THIN JDBC driver? What I had to do is to include the:

          AutoCommit=false

          in the ManagedConnectionFactoryProperties of the deployed ConnectionFactoryLoader service. It seems that autocommit is enabled by default in this driver.

          Attached I'm including my db-service.xml (although this will work only on JBoss 3.0)

          Regards, Peter

          • 2. Re: IllegalStateException: "removing bean lock and it has tx
            justin Newbie

            I'm having this same problem, except I'm using mssql with JBoss CVS head (3.1). Also, I'm using the mssql-service.xml file nearly as-is, and the microsoft-provided driver, as the comments in that dd recommend.

            My application works correctly with postgres, so I'm not sure I'm doing anything wrong in my beans. Besides, they are very straightforward. This exception is occurring on a bean that is completely 'textbook'- i based it on one of the sun j2ee tutorial examples. this exception is occurring when I do a findAll() and try to select a few attributes from one of the returned beans. none of the methods involved here are even written by me- all are default JBoss generated.

            As in the above example, I tried adding an 'AutoCommit' <config-property> in the 'ManagedConnectionFactoryProperties' attribute, but JBoss complains that it isn't relevant to this driver.
            Is there a similar solution for mssql as the oracle problem above?

            THanks in advance,
            Justin

            • 3. Re: IllegalStateException: "removing bean lock and it has tx
              Carmen Bastiaans Newbie

              Hi Peter,

              Could you please post your *-service.xml file that changes autocommit to false. I have looked everywhere and cannot find an example for JBoss 3.0

              Thanks
              Carmen