1 Reply Latest reply on Jul 10, 2002 4:28 PM by Dain Sundstrom

    java.lang.IllegalStateException: removing bean lock and it h

    Saroj Newbie

      Hi All,

      I am using JBOSS 3 and CMP 2.0. DB is Hypersonic.

      I have written a simple bean like this :

      ****************************************************
      public abstract class CustomerBean implements EntityBean
      {
      protected EntityContext ctx;

      public CustomerBean()
      {
      System.out.println("CustomerBean -- Constructor ");
      }

      // abstract get/set methods
      public abstract String getCustomerId();
      public abstract void setCustomerId(String customerId) ;

      public abstract String getCustomerName();
      public abstract void setCustomerName(String customerName);

      // ejb specific methods
      public void ejbActivate()
      {
      System.out.println("CustomerBean -- Activate ");
      }

      public void ejbPassivate()
      {
      System.out.println("CustomerBean -- Passivate ");
      }

      public void ejbRemove()
      {
      System.out.println("CustomerBean -- remove ");
      }

      public void ejbLoad()
      {
      System.out.println("CustomerBean -- ejbLoad ");
      }

      public void ejbStore()
      {
      System.out.println("CustomerBean -- ejbStore ");
      }

      public void setEntityContext(EntityContext ctx)
      {
      this.ctx = ctx;
      System.out.println("CustomerBean -- EntityContext ");
      }

      public void unsetEntityContext()
      {
      this.ctx = null;
      System.out.println("CustomerBean -- UnsetEntityContext ");
      }

      public void ejbPostCreate(String customerId, String customerName)
      {
      System.out.println("CustomerBean -- ejbPostCreate ");
      }

      // create a row - called when create() is called on Home Interface

      public CustomerPK ejbCreate(String customerId, String customerName) throws CreateException
      {

      this.setCustomerId(customerId);

      this.setCustomerName(customerName);

      CustomerPK c = new CustomerPK(customerId);

      System.out.println("calling PK = " + c.toString());

      return c;
      }
      }
      *******************************************
      DEPLOYMENT DESCRIPTOR IS: jbosscmp-jdbc.xml
      ********************************************

      <jbosscmp-jdbc>

      true
      <create-table>true</create-table>
      <remove-table>true</remove-table>
      <read-only>false</read-only>
      <time-out>0</time-out>
      <select-for-update>false</select-for-update>
      <pk-constraint>true</pk-constraint>
      <relation-mapping-style>foreign-key</relation-mapping-style>
      <read-ahead>
      on-load
      <page-size>500</page-size>
      <eager-load-group>group name</eager-load-group>
      </read-ahead>

      <enterprise-beans>

      <ejb-name>Customer</ejb-name>
      <table-name>Customer</table-name>

      <cmp-field>
      <field-name>customerId</field-name>
      <column-name>CUSTOMER_ID</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(10)</sql-type>
      </cmp-field>

      <cmp-field>
      <field-name>customerName</field-name>
      <column-name>CUSTOMER_NAME</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(100)</sql-type>

      </cmp-field>

      </enterprise-beans>
      </jbosscmp-jdbc>

      ************************
      ejb-jar.xml
      ************************
      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE ejb-jar PUBLIC
      "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
      "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar>
      RPM POC Sample Application
      <display-name>Customer EJB</display-name>

      <enterprise-beans>


      <display-name>Customer</display-name>
      <ejb-name>Customer</ejb-name>

      CustomerHome
      Customer

      <local-home>CustomerLocalHome</local-home>
      CustomerLocal

      <ejb-class>CustomerBean</ejb-class>

      <persistence-type>Container</persistence-type>

      <prim-key-class>CustomerPK</prim-key-class>

      <!-- prim-key-class>java.lang.String</prim-key-class -->
      False

      <cmp-version>2.x</cmp-version>

      <abstract-schema-name>CustomerBean</abstract-schema-name>

      <cmp-field>
      <field-name>customerId</field-name>
      </cmp-field>

      <cmp-field>
      <field-name>customerName</field-name>
      </cmp-field>

      <!-- primkey-field>customerId</primkey-field -->



      </enterprise-beans>

      <assembly-descriptor>
      <container-transaction>

      <ejb-name>Customer</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      ***************************
      SERVER LOG IS :
      *********************
      2002-07-10 16:25:55,251 INFO [STDOUT] CustomerBean -- ejbLoad
      2002-07-10 16:26:44,812 DEBUG [org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy] Resized cache for bean Customer: old capacity = 1000000, new capacity = 50
      2002-07-10 16:28:26,689 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] run: IdleRemover notifying pools, interval: 450000

      I get a exception like this:

      [java] java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      [java] Caught an unexpected exception while making contract!
      [java] java.rmi.ServerException: removing bean lock and it has tx set!; nested exception is:
      [java] java.lang.IllegalStateException: removing bean lock and it has tx set!
      [java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
      [java] at sun.rmi.transport.Transport$1.run(Transport.java:148)
      [java] at java.security.AccessController.doPrivileged(Native Method)
      [java] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      [java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      [java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      [java] at java.lang.Thread.run(Thread.java:536)
      [java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      [java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      [java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      [java] at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
      [java] at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:128)
      [java] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
      [java] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:73)
      [java] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:76)
      [java] at org.jboss.proxy.ejb.EntityInterceptor.invoke(EntityInterceptor.java:116)
      [java] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
      [java] at $Proxy1.getCustomerId(Unknown Source)
      [java] at test_ejbs.make_Customer(test_ejbs.java:84)
      [java] at test_ejbs.(test_ejbs.java:43)
      [java] at test_ejbs.main(test_ejbs.java:101)

      Any Idea why it is occurring? Any tips would be welcome.

      NOTE: IT'S WORKING ALL RIGHT WITH SIMPLE PRIMARY KEY FIELD.

      Why is it like that?

      Thanks,
      Saroj