2 Replies Latest reply on Apr 4, 2007 2:46 PM by William DeCoste

    ejb 3.0 optimistic locking problem

    paata lominadze Master

      i tryed to use locking into ejb 3.0
      here is my program fragment

      @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 :

      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.

        • 1. Re: ejb 3.0 optimistic locking problem
          paata lominadze Master

          on other version of the jboss application server (4.0.5)

          21:55:35,924 ERROR [STDERR] java.lang.NullPointerException
          21:55:35,925 ERROR [STDERR] at tempPackage.CountFasadeBean.update(CountFasadeBean.java:45)
          21:55:35,925 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          21:55:35,925 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          21:55:35,925 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          21:55:35,925 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
          21:55:35,925 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
          21:55:35,926 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
          21:55:35,926 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
          21:55:35,926 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,926 ERROR [STDERR] at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:71)
          21:55:35,926 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,926 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
          21:55:35,926 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,926 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:46)
          21:55:35,926 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,926 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
          21:55:35,926 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
          21:55:35,927 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,927 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
          21:55:35,927 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,927 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
          21:55:35,927 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,927 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
          21:55:35,927 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
          21:55:35,927 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,927 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
          21:55:35,927 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,927 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
          21:55:35,928 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          21:55:35,928 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:319)
          21:55:35,928 ERROR [STDERR] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
          21:55:35,928 ERROR [STDERR] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
          21:55:35,929 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
          21:55:35,929 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
          21:55:35,929 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
          21:55:35,929 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
          21:55:35,929 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
          21:55:35,929 INFO [STDOUT] ================ Exception Own ================
          
          


          • 2. Re: ejb 3.0 optimistic locking problem
            William DeCoste Apprentice

            What line is CountFasadeBean.update(CountFasadeBean.java:45)?? Is the injection failing?