9 Replies Latest reply on Feb 9, 2006 4:39 PM by George Ilias

    cannot jbpmSession.commitTransaction()

    George Ilias Newbie

      hello,

      i have the following code inside a method which is being called from an onMessage() method of an MDB :

      JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
      jbpmSession.beginTransaction();
      jbpmSession.getGraphSession().saveProcessInstance(processInstance);
      System.out.println("[ProcessExecution] Saved processInstance with ID:"+processInstance.getId());
      jbpmSession.commitTransaction();
      jbpmSession.close();
      

      And i m getting the following error and stack trace:
      22:36:31,515 ERROR [JDBCTransaction] JDBC commit failed
      java.sql.SQLException: You cannot commit during a managed transaction!
       at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:432)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:331)
       at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:139)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:115)
       at org.jbpm.db.JbpmSession.commitTransaction(JbpmSession.java:103)
       at com.adminsys.ejb.ProcessExecutionFacadeBean.storeProcessInstance(ProcessExecutionFacadeBean.java:126)
       at com.adminsys.ejb.ProcessExecutionFacadeBean.endTaskOfProcess(ProcessExecutionFacadeBean.java:284)
       at com.adminsys.ejb.TaskEvaluatedBean.onMessage(TaskEvaluatedBean.java:102)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
       at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:475)
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
       at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:101)
       at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
       at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
       at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:94)
       at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
       at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:389)
       at org.jboss.ejb.Container.invoke(Container.java:873)
       at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:1077)
       at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1379)
       at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
       at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:904)
       at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:160)
       at org.jboss.mq.SpySession.run(SpySession.java:333)
       at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
       at java.lang.Thread.run(Thread.java:536)
      22:36:31,546 ERROR [JbpmSession] org.hibernate.TransactionException: JDBC commit failed
      22:36:31,546 INFO [STDOUT] java.lang.RuntimeException: couldn't commit transaction
      22:36:31,546 INFO [STDOUT] at org.jbpm.db.JbpmSession.commitTransaction(JbpmSession.java:107)
      22:36:31,546 INFO [STDOUT] at com.adminsys.ejb.ProcessExecutionFacadeBean.storeProcessInstance(ProcessExecutionFacadeBean.java:126)
      22:36:31,546 INFO [STDOUT] at com.adminsys.ejb.ProcessExecutionFacadeBean.endTaskOfProcess(ProcessExecutionFacadeBean.java:284)
      22:36:31,546 INFO [STDOUT] at com.adminsys.ejb.TaskEvaluatedBean.onMessage(TaskEvaluatedBean.java:102)
      22:36:31,546 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      22:36:31,546 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      22:36:31,546 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      22:36:31,546 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
      22:36:31,546 INFO [STDOUT] at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      22:36:31,546 INFO [STDOUT] at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:475)
      22:36:31,562 INFO [STDOUT] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:
      149)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:101)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:94)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:389)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:873)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:1077)
      22:36:31,562 INFO [STDOUT] at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1379
      )
      22:36:31,562 INFO [STDOUT] at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
      22:36:31,578 INFO [STDOUT] at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:904)
      22:36:31,578 INFO [STDOUT] at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:160)
      22:36:31,578 INFO [STDOUT] at org.jboss.mq.SpySession.run(SpySession.java:333)
      22:36:31,578 INFO [STDOUT] at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
      22:36:31,578 INFO [STDOUT] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
      22:36:31,578 INFO [STDOUT] at java.lang.Thread.run(Thread.java:536)
      22:36:31,578 INFO [STDOUT] Caused by: org.hibernate.TransactionException: JDBC commit failed
      22:36:31,578 INFO [STDOUT] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:130)
      22:36:31,578 INFO [STDOUT] at org.jbpm.db.JbpmSession.commitTransaction(JbpmSession.java:103)
      22:36:31,578 INFO [STDOUT] ... 29 more
      22:36:31,593 INFO [STDOUT] Caused by: java.sql.SQLException: You cannot commit during a managed transaction!
      22:36:31,593 INFO [STDOUT] at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java
      :432)
      22:36:31,593 INFO [STDOUT] at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:331)
      22:36:31,593 INFO [STDOUT] at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:139)
      22:36:31,593 INFO [STDOUT] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:115)
      22:36:31,593 INFO [STDOUT] ... 30 more
      
      


      If i leave out the jbpmSession.commitTransaction(); i have problem with the persistence of my processInstance later on in the execution of my code; it's not retrieved correct from the db.
      Any ideas?
      Thanks