3 Replies Latest reply on Sep 11, 2002 2:13 PM by Dain Sundstrom

    CMR Problem in JBoss.Please help!

    Devon Coleman Newbie

      Hello:

      I am receiving the following error:

      2002-09-05 19:10:43,920 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException, causedBy:
      java.lang.IllegalStateException: removing bean lock and it has tx set!


      I am using CMP2.0 with JBOSS 3.0 with a mysql db. There are two entity beans (CustomerEJB and AddressEJB)each using a Defined Value Class to populate thier non-primary key fields.

      There is a one to one unidirectional relationship between the EJB (a Customer and have a Address). In this relationship the "address_id" column in the Customer table is the foreign key for the "id" column in the Address table. In this case creating a CustomerEJB will create an AddressEJB(which is an extension of the
      EJBLocalObject). When I run the client application the error detailed above occurs. It appears that the address_id column in the Customer table is unable to be updated with the id column from the Address table. All other columns in both tables are properly set though.

      Here is the error I receive:



      Below is my ejb-jar and jbosscmp-jdbc xml files:

      Here is the ejb-jar.xml:

      <ejb-jar>
      <enterprise-beans>

      <ejb-name>CustomerEJB</ejb-name>
      com.ejbproject.Customer.CustomerHomeRemote
      com.ejbproject.Customer.CustomerRemote
      <ejb-class>com.ejbproject.Customer.CustomerBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Customer</abstract-schema-name>
      <cmp-field><field-name>id</field-name></cmp-field>
      <cmp-field><field-name>lastName</field-name></cmp-field>
      <cmp-field><field-name>firstName</field-name></cmp-field>
      <cmp-field><field-name>hasGoodCredit</field-name></cmp-field>
      <primkey-field>id</primkey-field>
      <security-identity><use-caller-identity/></security-identity>


      <ejb-name>AddressEJB</ejb-name>
      <local-home>com.ejbproject.Customer.AddressHomeLocal</local-home>
      com.ejbproject.Customer.AddressLocal
      <ejb-class>com.ejbproject.Customer.AddressBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Address</abstract-schema-name>
      <cmp-field><field-name>id</field-name></cmp-field>
      <cmp-field><field-name>street</field-name></cmp-field>
      <cmp-field><field-name>city</field-name></cmp-field>
      <cmp-field><field-name>state</field-name></cmp-field>
      <cmp-field><field-name>zip</field-name></cmp-field>
      <primkey-field>id</primkey-field>
      <security-identity><use-caller-identity/></security-identity>

      </enterprise-beans>


      <ejb-relation>
      <ejb-relation-name>Customer-Address</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Customer-has-an-Address</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>CustomerEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>homeAddress</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Address-belongs-to-Customer</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>AddressEJB</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>


      Here is the jbosscmp-jdbc.xml:

      <jbosscmp-jdbc>

      java:/MySqlDS
      <datasource-mapping>mySQL</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>

      <enterprise-beans>

      <ejb-name>CustomerEJB</ejb-name>
      <table-name>Customer</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>ID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      <column-name>last_name</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      <column-name>first_name</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>hasGoodCredit</field-name>
      <column-name>has_good_credit</column-name>
      </cmp-field>


      <ejb-name>AddressEJB</ejb-name>
      <table-name>Address</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>ID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>street</field-name>
      <column-name>street</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      <column-name>city</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>state</field-name>
      <column-name>state</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>zip</field-name>
      <column-name>zip</column-name>
      </cmp-field>



      </enterprise-beans>


      <ejb-relation>
      <ejb-relation-name>Customer-Address</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Customer-has-an-Address
      </ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Address-belongs-to-Customer
      </ejb-relationship-role-name>
      <fk-constraint>false</fk-constraint>
      <key-fields>
      <key-field>
      <field-name>id</field-name>
      <column-name>address_id</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      </ejb-relation>

      </jbosscmp-jdbc>

      The question is what am I doing wrong in my relationship sections of the xml deployment files,what is causing the error and what does it exactly mean?

      Thanks for any help with this problem. Please be as specific as possible with your suggestions. Thanks in advance. Below is the extended error listing

      Devon Coleman

      2002-09-05 19:10:43,920 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException, causedBy:
      java.lang.IllegalStateException: removing bean lock and it has tx set!
      at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.removeRef(QueuedPessimisticEJBLock.java:469)
      at org.jboss.ejb.BeanLockManager.removeLockRef(BeanLockManager.java:78)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:124)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:296)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy45.getPrimaryKey(Unknown Source)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JDBCCMRFieldBridge.java:625)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setValue(JDBCCMRFieldBridge.java:563)
      at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:125)
      at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
      at com.ejbproject.Customer.CustomerBean$Proxy.setHomeAddress()
      at com.ejbproject.Customer.CustomerBean.setAddress(CustomerBean.java:92)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:30)
      at sun.reflect.InflatableMethodAccessorImpl.invoke(InflatableMethodAccessorImpl.java:48)
      at java.lang.reflect.Method.invoke(Method.java:306)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1197)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:190)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:340)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:193)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.Container.invoke(Container.java:705)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:362)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:30)
      at sun.reflect.InflatableMethodAccessorImpl.invoke(InflatableMethodAccessorImpl.java:48)
      at java.lang.reflect.Method.invoke(Method.java:306)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:256)
      at sun.rmi.transport.Transport$1.run(Transport.java:156)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:152)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:469)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
      at java.lang.Thread.run(Thread.java:579)