i tryed to use locking into ejb 3.0
here is my program fragment
Code:
@Stateful
@Remote(CountFasade.class)
public class CountFasadeBean implements CountFasade {
@PersistenceContext(unitName = "Test", type = PersistenceContextType.EXTENDED)
private EntityManager oracleManager;
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void update(long start, long end) throws Exception {
try {
System.out.println("================ Start ================");
Test test = oracleManager.find(Test.class, 1100011L);
System.out.println("test id = " + test.getId());
System.out.println("test name = " + test.getName());
System.out.println("test surname = " + test.getSurname());
System.out.println("test age = " + test.getAge());
oracleManager.lock(test, LockModeType.WRITE);
test.setSurname("From Javaaaa");
oracleManager.merge(test);
Thread.sleep((1000 * 20));
oracleManager.flush();
System.out.println("================ End ================");
} catch (Exception e) {
e.printStackTrace();
System.out
.println("================ Exception Own ================");
}
}
}
but when i tryed to use this method from client i got an error like this :
Code:
18:04:48,423 ERROR [STDERR] java.lang.NullPointerException
18:04:48,424 ERROR [STDERR] at org.hibernate.persister.entity.AbstractEntityPersister.lock(AbstractEntityPersister.java:1282)
18:04:48,424 ERROR [STDERR] at org.hibernate.event.def.AbstractLockUpgradeEventListener.upgradeLock(AbstractLockUpgradeEventListener.java:88)
18:04:48,424 ERROR [STDERR] at org.hibernate.event.def.DefaultLockEventListener.onLock(DefaultLockEventListener.java:64)
18:04:48,424 ERROR [STDERR] at org.hibernate.impl.SessionImpl.fireLock(SessionImpl.java:586)
18:04:48,424 ERROR [STDERR] at org.hibernate.impl.SessionImpl.lock(SessionImpl.java:578)
18:04:48,424 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.lock(AbstractEntityManagerImpl.java:337)
18:04:48,424 ERROR [STDERR] at org.jboss.ejb3.entity.ExtendedEntityManager.lock(ExtendedEntityManager.java:89)
18:04:48,424 ERROR [STDERR] at tempPackage.CountFasadeBean.update(CountFasadeBean.java:51)
18:04:48,424 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:04:48,424 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
18:04:48,425 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
18:04:48,425 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
18:04:48,425 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
18:04:48,425 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
18:04:48,425 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
18:04:48,425 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,425 ERROR [STDERR] at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:71)
18:04:48,425 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,425 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
18:04:48,428 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,428 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
18:04:48,428 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,428 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
18:04:48,428 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
18:04:48,428 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,428 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
18:04:48,428 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,428 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
18:04:48,428 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,429 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
18:04:48,429 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,429 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
18:04:48,429 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,458 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
18:04:48,458 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
18:04:48,458 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:297)
18:04:48,458 ERROR [STDERR] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
18:04:48,458 ERROR [STDERR] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
18:04:48,488 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
18:04:48,488 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
18:04:48,488 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
18:04:48,488 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
18:04:48,488 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
can anybody help me ?
Regards,
Paata.