We were investigating a problem in our application where we had a situation in which we
needed LockModeType.WRITE - but we ran into troubles with it. Therefore I created a small
test session and a simple entitybean with an id, name and description field.
We are using JBoss 4.0.5.GA as obtained through the forum.
Session bean code;
public void modThingy(Thingy thingy) {
| Thingy dbThingy = manager.find(Thingy.class, thingy.getId());
| dbThingy.setDescription(thingy.getDescription());
| manager.lock(dbThingy, LockModeType.READ);
| manager.persist(dbThingy);
| }
We can add and delete entitybeans through the session bean, but as soon as we try to use
the modify method on the SB, which contains the write lock statement, we get the NPE.
Exception in thread "main" javax.ejb.EJBException:
java.lang.NullPointerException
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
|
| ...
|
| Caused by: java.lang.NullPointerException
| at
org.hibernate.persister.entity.AbstractEntityPersister.lock(AbstractEntityPersister.java:1290)
| at
org.hibernate.event.def.AbstractLockUpgradeEventListener.upgradeLock(AbstractLockUpgradeEventListener.java:88)
| at
org.hibernate.event.def.DefaultLockEventListener.onLock(DefaultLockEventListener.java:64)
| at org.hibernate.impl.SessionImpl.fireLock(SessionImpl.java:584)
| at org.hibernate.impl.SessionImpl.lock(SessionImpl.java:576)
| at
org.hibernate.ejb.AbstractEntityManagerImpl.lock(AbstractEntityManagerImpl.java:375)
| at
org.jboss.ejb3.entity.TransactionScopedEntityManager.lock(TransactionScopedEntityManager.java:101)
I already found the following posts from half a year ago on this problem;
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3940780#...
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961545#...
If I remove the manager.lock() statement, no exceptions are thrown. If I replace the
LockModeType.WRITE with a LockModeType.READ - also no exceptions are thrown.
Is this still a known problem in JBoss 4.0.5.GA ?
If yes, is there any plan on resolving this issue ?
Are there alternatives for using LockModeType.WRITE ?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016256#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...