0 Replies Latest reply on Jul 5, 2011 6:33 PM by Fabin Riako

    Transaction is not active when calling EntityManager.find

    Fabin Riako Newbie

      Hi All,


      I am using a @Asynchronous method to execute a database stored procedure which sometimes take more than 1-2 hours to finish. After I go the return value from the stored procedure I need to update an Entity Bean. I am using  entityManager.find to find the Entity Bean but the statement throwing the following error.


      2011-07-05 15:41:53,357 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id a40363e:9aae:4e135a20:1044 invoked while multiple threads active within it.
      2011-07-05 15:41:53,358 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action a40363e:9aae:4e135a20:1044 aborting with 1 threads active!
      2011-07-05 15:41:53,358 WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: null
      2011-07-05 15:41:53,358 ERROR [org.hibernate.util.JDBCExceptionReporter] Transaction is not active: tx=TransactionImple < ac, BasicAction: a40363e:9aae:4e135a20:df9 status: ActionStatus.ABORTED >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a40363e:9aae:4e135a20:df9 status: ActionStatus.ABORTED >)
      2011-07-05 15:41:53,359 ERROR [STDERR] javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:107)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at com.nfsmith.partmatch.util.Util.processPartMatch(Util.java:366)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at sun.reflect.GeneratedMethodAccessor328.invoke(Unknown Source)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:592)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.util.Work.workInTransaction(Work.java:40)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
      2011-07-05 15:41:53,359 ERROR [STDERR]  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:50)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at com.nfsmith.partmatch.util.Util_$$_javassist_10.processPartMatch(Util_$$_javassist_10.java)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at sun.reflect.GeneratedMethodAccessor327.invoke(Unknown Source)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:592)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.async.AsynchronousInvocation.call(AsynchronousInvocation.java:52)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.async.Asynchronous.executeInContexts(Asynchronous.java:76)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.async.Asynchronous.execute(Asynchronous.java:45)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:240)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
      2011-07-05 15:41:53,360 ERROR [STDERR] Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
      2011-07-05 15:41:53,360 ERROR [STDERR]  at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:140)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.loader.Loader.doQuery(Loader.java:673)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.loader.Loader.doList(Loader.java:2220)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.loader.Loader.list(Loader.java:2099)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:341)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:82)
      2011-07-05 15:41:53,361 ERROR [STDERR]  ... 34 more
      2011-07-05 15:41:53,361 ERROR [STDERR] Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a40363e:9aae:4e135a20:df9 status: ActionStatus.ABORTED >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a40363e:9aae:4e135a20:df9 status: ActionStatus.ABORTED >)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:96)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:47)
      2011-07-05 15:41:53,361 ERROR [STDERR]  at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
      2011-07-05 15:41:53,361 ERROR [STDERR]  ... 48 more
      2011-07-05 15:41:53,362 ERROR [STDERR] Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a40363e:9aae:4e135a20:df9 status: ActionStatus.ABORTED >
      2011-07-05 15:41:53,362 ERROR [STDERR]  at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:319)
      2011-07-05 15:41:53,362 ERROR [STDERR]  at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:403)
      2011-07-05 15:41:53,362 ERROR [STDERR]  at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:850)
      2011-07-05 15:41:53,362 ERROR [STDERR]  at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:90)
      2011-07-05 15:41:53,362 ERROR [STDERR]  ... 50 more
      2011-07-05 15:41:53,362 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_40] - Abort called on already aborted atomic action a40363e:9aae:4e135a20:df9
      2011-07-05 15:41:53,363 ERROR [org.quartz.core.JobRunShell] Job DEFAULT.1972ef70:130fb980cfc:-7e78 threw an unhandled Exception: 
      java.util.EmptyStackException
              at java.util.Stack.peek(Stack.java:79)
              at java.util.Stack.pop(Stack.java:61)
              at org.jboss.seam.transaction.SeSynchronizations.afterTransactionRollback(SeSynchronizations.java:45)
              at org.jboss.seam.transaction.UTTransaction.rollback(UTTransaction.java:70)
              at org.jboss.seam.util.Work.workInTransaction(Work.java:53)
              at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:50)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
              at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
              at com.nfsmith.partmatch.util.Util_$$_javassist_10.processPartMatch(Util_$$_javassist_10.java)
              at sun.reflect.GeneratedMethodAccessor327.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:592)
              at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
              at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
              at org.jboss.seam.async.AsynchronousInvocation.call(AsynchronousInvocation.java:52)
              at org.jboss.seam.async.Asynchronous.executeInContexts(Asynchronous.java:76)
              at org.jboss.seam.async.Asynchronous.execute(Asynchronous.java:45)
              at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:240)
              at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
              at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
      2011-07-05 15:41:53,363 ERROR [org.quartz.core.ErrorLogger] Job (DEFAULT.1972ef70:130fb980cfc:-7e78 threw an exception.
      org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.util.EmptyStackException]
              at org.quartz.core.JobRunShell.run(JobRunShell.java:214)
              at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
      * Nested Exception (Underlying Cause) ---------------
      java.util.EmptyStackException
              at java.util.Stack.peek(Stack.java:79)
              at java.util.Stack.pop(Stack.java:61)
              at org.jboss.seam.transaction.SeSynchronizations.afterTransactionRollback(SeSynchronizations.java:45)
              at org.jboss.seam.transaction.UTTransaction.rollback(UTTransaction.java:70)
              at org.jboss.seam.util.Work.workInTransaction(Work.java:53)
              at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:50)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
              at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
              at com.nfsmith.partmatch.util.Util_$$_javassist_10.processPartMatch(Util_$$_javassist_10.java)
              at sun.reflect.GeneratedMethodAccessor327.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:592)
              at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
              at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
              at org.jboss.seam.async.AsynchronousInvocation.call(AsynchronousInvocation.java:52)
              at org.jboss.seam.async.Asynchronous.executeInContexts(Asynchronous.java:76)
              at org.jboss.seam.async.Asynchronous.execute(Asynchronous.java:45)
              at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:240)
              at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
              at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
      




      @Asynchronous
      @Transactional(TransactionPropagationType.REQUIRED)
      public void Match(String processType){
      .
      .
      .
      entityManager.find();--->Error
      .
      }
      



      Any suggestions.


      Thanks