JBoss Community

Re: jBPM processes started from Java code dont show up in jBPM process console

created by Maïté Braud in jBPM - View the full discussion

Now I'm hitting another problem. I've been doing some extensive search on the forum and found several posts but none of them solved my problem.

 

I can now start processes from java code and I see them appearing in the jBPM-console allowing me to complete the first human task in my workflow but later on I get a OptimisticLockException.

 

What I am actually doing is that most of the service tasks in my process are asynchronous, that is I'm sending web service requests to external systems which calls me back asynchronously once they're finished. I then call the ksession.signalEvent (kSession is persisted in memory) in order to finish the service task and start the next one in my process.

Now this all works fine when I start the process from the jBPM-console but if I start the process from java code, I get the following stacktrace when I try to call ksession.signalEvent.

I get the same error whether my java code create a new session or reuse the one created by the jBPM-console.

 

Any idea?

 

Here is the stacktrace:

2012-01-20 10:04:53,132 WARN [Thread-66] [org.drools.persistence.jta.JtaTransactionManager] - Unable to commit transaction

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#4]

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

          at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1334)

          at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1315)

          at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1321)

          at org.hibernate.ejb.AbstractEntityManagerImpl$3.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1235)

          at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:122)

          at org.hibernate.transaction.synchronization.HibernateSynchronizationImpl.beforeCompletion(HibernateSynchronizationImpl.java:51)

          at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:478)

          at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:193)

          at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120)

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

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

          at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.signalEvent(CommandBasedStatefulKnowledgeSession.java:209)

          at eu.ensure.tessella.pdalm.service.ManagerPersistence.sendCompletedMessageByWorkItem(ManagerPersistence.java:62)

          at eu.ensure.tessella.pdalm.service.StepCompleteServiceImpl$1.run(StepCompleteServiceImpl.java:51)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:117)

          ... 10 more

2012-01-20 10:04:53,136 ERROR [Thread-66] [org.drools.persistence.SingleSessionCommandService] - Could not commit session

java.lang.RuntimeException: Unable to commit transaction

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

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

          at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.signalEvent(CommandBasedStatefulKnowledgeSession.java:209)

          at eu.ensure.tessella.pdalm.service.ManagerPersistence.sendCompletedMessageByWorkItem(ManagerPersistence.java:62)

          at eu.ensure.tessella.pdalm.service.StepCompleteServiceImpl$1.run(StepCompleteServiceImpl.java:51)

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

Caused by: 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#4]

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

          at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1334)

          at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1315)

          at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1321)

          at org.hibernate.ejb.AbstractEntityManagerImpl$3.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1235)

          at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:122)

          at org.hibernate.transaction.synchronization.HibernateSynchronizationImpl.beforeCompletion(HibernateSynchronizationImpl.java:51)

          at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:478)

          at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:193)

          at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120)

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

          ... 5 more

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

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

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

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

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

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

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

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

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

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

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

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

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

          at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:117)

          ... 10 more

 

Any help would be highly appreciated.

Reply to this message by going to Community

Start a new discussion in jBPM at Community