3 Replies Latest reply on Nov 21, 2002 6:26 AM by Michael Olszynski

    EJB 2.0 Compund Key problems

    Michael Olszynski Newbie

      Hello,

      I try to write a sample application to get in the topic of EJB 2.0. If u can help me, it´d be greate. It´s for my thesis and REALLY urgent!!!
      I can deploy and use my application if I only have one primary key. But I need to have two primary keys (one compund key). I alays get an error message which says:


      BankClient
      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.ServerException: removing bean lock and it has tx set!; nested exception is:
      java.lang.IllegalStateException: removing bean lock and it has tx set!
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
      at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:128)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:73)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:76)
      at org.jboss.proxy.ejb.EntityInterceptor.invoke(EntityInterceptor.java:116)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
      at $Proxy1.getAccDescription(Unknown Source)
      at BankClient.create(BankClient.java:79)
      at BankClient.main(BankClient.java:92)
      Caused by: java.rmi.ServerException: removing bean lock and it has tx set!; nested exception is:
      java.lang.IllegalStateException: removing bean lock and it has tx set!
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:119)
      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:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      Caused by: 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)
      ... 20 more
      run..
      findbyprimkey done
      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.ServerException: removing bean lock and it has tx set!; nested exception is:
      java.lang.IllegalStateException: removing bean lock and it has tx set!
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
      at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:128)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:73)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:76)
      at org.jboss.proxy.ejb.EntityInterceptor.invoke(EntityInterceptor.java:116)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
      at $Proxy1.getAccDescription(Unknown Source)
      at BankClient.run(BankClient.java:64)
      at BankClient.main(BankClient.java:93)
      Caused by: java.rmi.ServerException: removing bean lock and it has tx set!; nested exception is:
      java.lang.IllegalStateException: removing bean lock and it has tx set!
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:119)
      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:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      Caused by: 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)
      ... 20 more

      My BankAccountBean.java

      package bankaccount;

      import javax.ejb.*;


      public abstract class BankAccountBean implements EntityBean {

      private EntityContext theContext;


      public BankAccountBean() {
      final String name = "BankAccountBean";
      }

      //Die create-Methode des Home-Interface

      // WORKING: public String ejbCreate(String accNo,
      public BankAccountPK ejbCreate(String accNo,
      String accDescription,
      float initialBalance)
      throws CreateException
      {
      setAccountNumber(accNo);
      setAccountDescription(accDescription);
      setAccountBalance(initialBalance);
      return null;
      }

      public void ejbPostCreate(String accNo,
      String accDescription,
      float initialBalance)
      throws CreateException
      {
      }

      //Abstrakte getter-/setter-Methoden

      public abstract String getAccountNumber();
      public abstract void setAccountNumber(String acn);

      public abstract String getAccountDescription();
      public abstract void setAccountDescription(String acd);

      public abstract float getAccountBalance();
      public abstract void setAccountBalance(float acb);


      //Die Methoden des Remote-Interface

      public String getAccNumber() {
      return getAccountNumber();
      }

      public String getAccDescription() {
      return getAccountDescription();
      }

      public float getBalance() {
      return getAccountBalance();
      }

      public void increaseBalance(float amount) {
      float acb = getAccountBalance();
      acb += amount;
      setAccountBalance(acb);
      }

      public void decreaseBalance(float amount) {
      float acb = getAccountBalance();
      acb -= amount;
      setAccountBalance(acb);
      }


      public void setEntityContext(EntityContext ctx) {
      theContext = ctx;
      }

      public void unsetEntityContext() {
      theContext = null;
      }

      public void ejbRemove()
      throws RemoveException
      {
      }

      public void ejbActivate() {
      }

      public void ejbPassivate() {
      }

      public void ejbLoad() {
      }

      public void ejbStore() {

      }
      }


      My BankAccountHome.java

      package bankaccount;

      import java.rmi.RemoteException;
      import javax.ejb.*;

      public interface BankAccountHome extends EJBHome {

      //Erzeugen eines Kontos
      public BankAccount create(String accNo,
      String accDescription,
      float initialBalance)
      throws CreateException, RemoteException;

      //Finden eines bestimmten Kontos
      public BankAccount findByPrimaryKey(BankAccountPK accPK)
      // WORKING: public BankAccount findByPrimaryKey(String accPK)

      throws FinderException, RemoteException;

      }

      My BankAccountPK.java

      package bankaccount;

      public class BankAccountPK implements java.io.Serializable {

      public String accountNumber;
      public String accountDescription;

      public BankAccountPK(String accountNumber, String accountDescription) {
      this.accountNumber = accountNumber;
      this.accountDescription = accountDescription;
      }

      public BankAccountPK() {
      accountNumber = new String();
      accountDescription = new String();
      }


      public int hashCode() {

      return accountNumber.hashCode();
      }

      public String getAccountNumber(){
      return accountNumber;
      }

      public String getAccountDescription(){
      return accountDescription;
      }

      public boolean equals(Object other) {
      // return true;
      return accountNumber.equals(other);
      }


      public String toString() {
      return accountNumber;
      }
      }







      PLEASE, ANY HELP IS WELCOME