aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Why is my bean locked when i call methods on it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Why is my bean locked when i call methods on it" Watch "Why is my bean locked when i call methods on it" New topic
Author

Why is my bean locked when i call methods on it

David Rocks
Ranch Hand

Joined: Apr 24, 2001
Posts: 162
Hi,
I have a been that when i call this line in ejbActivate()
id = new Integer( (String)context.getPrimaryKey() ).intValue() ;
i get an exception, see below. i don't know how i could have locked the bean, container transaction probably. i would think it is a depoyment config thing but i am not to sure. has anybody seen this and know how to fix it?
thanks for any help.
[INFO,Default] UserEntityBean::ejbActivate()
[ERROR,UserImpl] TRANSACTION ROLLBACK EXCEPTION:
javax.transaction.TransactionRolledbackException: removing bean lock and it has tx set!; nested exception is:
java.lang.IllegalStateException: removing bean lock and it has tx set!
java.lang.IllegalStateException: removing bean lock and it has tx set!
at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.removeRef(QueuedPessimisticEJBLock.java:441)
at org.jboss.ejb.BeanLockManager.removeLockRef(BeanLockManager.java:78)
at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:142)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:602)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:428)
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:504)
at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335)
at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:133)
at $Proxy97.getId(Unknown Source)
at com.users.EJB.UserManagerSessionBean.isValidUser(UserManagerSessionBean.java:81)
at java.lang.reflect.Method.invoke(Native Method)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:542)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:82)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Well, from about 40,000 feet up, I'd say that you're probably trying to do something simple the hard way.
It would appear that the container has invoked ejbActivate() in response to a bean lookup request. That started a transaction context. Now you're attempting to invoke a bean method - which ITSELF starts a transaction context - while running within that context. Thereby violating the transaction rules you are configured for.
However, before you run off and try all sorts of hacking around on transactions to fix it, consider what you are trying to do. To me, it appears that you've simply trying to find out what your basic primary key value is, prepraratory to loading up the persisted values of a BMP EJB. I think you can find a shorter route than going through the context if you try - after all, the primary key (you appear to have a PK class rather than a wrapper-class object) is already part of the EJB object.
I don't have any samples handy at the moment, but you might want to chase one down and verify that.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why is my bean locked when i call methods on it