3 Replies Latest reply on Sep 8, 2012 1:32 PM by Elton Plath

    Problem in completing human tasks in CBHornetQWSHumanTaskHandler with multiple ksessions.

    Dsire krish Newbie

      I create a ksession for every processinstance.

      The process instances are created without any problem.But when i  complete the task of the process instances.

      Im getting this exception

       

      javax.persistence.OptimisticLockException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.drools.persistence.info.SessionInfo#1]

                at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:630)

                at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:588)

       

      I understand that another thread is trying to access a row which is already deleted from the table after completing it.

      But I have to use multiple ksessions. How would i use those without getting this exception.

      I have attached the class files for reference.

        • 1. Re: Problem in completing human tasks in CBHornetQWSHumanTaskHandler with multiple ksessions.
          Maciej Swiderski Master

          could you provide bit more details about this case, like server.log with complete stacktrace and the process definition or at least description of what the process do to understand what sort of concurrency issue you have.

           

          Cheers

          • 2. Re: Problem in completing human tasks in CBHornetQWSHumanTaskHandler with multiple ksessions.
            Dsire krish Newbie

            2012-08-23 23:18:38,534 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] (NioProcessor-8) Could not synchronize database state with session

            org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.persistence.processinstance.ProcessInstanceInfo#88]

                      at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1792)

                      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2435)

                      at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335)

                      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635)

                      at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)

                      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)

                      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)

                      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)

                      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)

                      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)

                      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)

                      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)

                      at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:504)

                      at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)

                      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)

                      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)

                      at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)

                      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1423)

                      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137)

                      at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)

                      at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:162)

                      at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179)

                      at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:359)

                      at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150)

                      at org.jbpm.process.workitem.wsht.CommandBasedWSHumanTaskHandler$GetResultContentResponseHandler.execute(CommandBasedWSHumanTaskHandler.java:371)

                      at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153)

                      at org.jbpm.task.service.mina.MinaTaskClientHandler.messageReceived(MinaTaskClientHandler.java:47)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:716)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)

                      at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:427)

                      at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:245)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)

                      at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:692)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:645)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:634)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:66)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1078)

                      at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                      at java.lang.Thread.run(Thread.java:619)

            2012-08-23 23:18:38,581 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (NioProcessor-8) [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@bf7b75

            javax.persistence.OptimisticLockException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.persistence.processinstance.ProcessInstanceInfo#88]

                      at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:630)

                      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:588)

                      at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:513)

                      at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)

                      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)

                      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)

                      at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)

                      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1423)

                      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137)

                      at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)

                      at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:162)

                      at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179)

                      at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:359)

                      at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150)

                      at org.jbpm.process.workitem.wsht.CommandBasedWSHumanTaskHandler$GetResultContentResponseHandler.execute(CommandBasedWSHumanTaskHandler.java:371)

                      at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153)

                      at org.jbpm.task.service.mina.MinaTaskClientHandler.messageReceived(MinaTaskClientHandler.java:47)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:716)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)

                      at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:427)

                      at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:245)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)

                      at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

                      at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:692)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:645)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:634)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:66)

                      at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1078)

                      at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                      at java.lang.Thread.run(Thread.java:619)

            Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.persistence.processinstance.ProcessInstanceInfo#88]

                      at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1792)

                      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2435)

                      at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335)

                      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635)

                      at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)

                      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)

                      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)

                      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)

                      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)

                      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)

                      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)

                      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)

                      at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:504)

                      ... 35 more

             

             

            This is the exception that im getting...

            • 3. Re: Problem in completing human tasks in CBHornetQWSHumanTaskHandler with multiple ksessions.
              Elton Plath Newbie

              Hi,

               

              Did you find an answer? I am experiencing the same problem - it seems multiple threads (each ksession active with its own work item handler) is trying to complete the same workitem/process instance.