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 The Software Craftsman this week in the Agile 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

Why is my bean locked when i call methods on it

David Rocks
Ranch Hand

Joined: Apr 24, 2001
Posts: 162
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()
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(
at org.jboss.ejb.BeanLockManager.removeLockRef(
at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(
at org.jboss.ejb.plugins.LogInterceptor.invoke(
at org.jboss.ejb.EntityContainer.invoke(
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(
at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(
at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(
at $Proxy97.getId(Unknown Source)
at com.users.EJB.UserManagerSessionBean.isValidUser(
at java.lang.reflect.Method.invoke(Native Method)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16541

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.
I agree. Here's the link:
subject: Why is my bean locked when i call methods on it