Guilherme Telles [
https://community.jboss.org/people/guilherme.telles] created the
discussion
"[JBPM 5.4] - Transaction / Concurrency problem"
To view the discussion, visit:
https://community.jboss.org/message/832169#832169
--------------------------------------------------------------
Hi, I'm having some trouble with concurrency, hope you guys can help me
Here's the stack trace:
================================================================================================================================
15:32:16,379 ERROR [org.drools.persistence.SingleSessionCommandService] (Thread-79) Could
not commit session: java.lang.RuntimeException: Unable to commit transaction
at
org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:182)
[drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:376)
[drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$GetResultContentResponseHandler.execute(AsyncGenericHTWorkItemHandler.java:302)
[jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]
at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153)
[jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]
at
org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56)
[jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]
at
org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122)
[jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not commit
transaction.
at
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1177)
at
com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:117)
at
com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
at
org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:167)
at
org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179)
[drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]
... 7 more
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#1]
at
org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:1389)
[hibernate-entitymanager-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1307)
[hibernate-entitymanager-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1288)
[hibernate-entitymanager-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1294)
[hibernate-entitymanager-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1480)
[hibernate-entitymanager-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at
com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)
at
com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)
at
com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:164)
at
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)
... 11 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#1]
at
org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2365)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3017)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2915)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3244)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:113)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:276)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1127)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:325)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
at
org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:104)
[hibernate-core-4.1.0.Final.jar:4.1.0.Final]
... 17 more
================================================================================================================================
I'm using JBPM 5.4, Jboss AS 7.1.1, Spring 3
The Knowledge Base it's been kept in another server.
This is how I start my HornetQTaskServer:
(Do I really need to start it? I've been trying to connect to the one that's
supposed to come with jBPM. But, in that case, even though I can start the process, not a
single task is persisted. I can only complete the process if I set the
AsyncHornetQHTWorkItemHandler IP to localhost and start the HornetQ locally )
{code}
try{
TaskService taskService = new TaskService(getEntityManagerFactoryJbpm(),
SystemEventListenerFactory.getSystemEventListener());
HornetQTaskServer server = new HornetQTaskServer(taskService,
"localhost", 5445);
if(!server.isRunning()) {
Thread thread = new Thread(server);
thread.start();
}
} catch(Exception e) {
LOGGER.warn("HornetQ Task Server já iniciado");
}
{code}
My Environment:
{code}
public Environment getEnvironment() {
if(environment == null) {
LOGGER.info("CREATING NEW ENVIRONMENT");
environment = KnowledgeBaseFactory.newEnvironment();
environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY,
getEntityManagerFactoryJbpm());
}
return environment;
}
{code}
How I register my handlers:
{code}
public static void registerHandlers(StatefulKnowledgeSession kSession) {
LOGGER.info("REGISTERING HANDLERS...");
final EmailHandler emailHandler = new EmailHandler();
final OrcamentoHandler orcamentoHandler = new OrcamentoHandler();
final MudarStatusHandler mudarStatusHandler = new MudarStatusHandler();
kSession.getWorkItemManager().registerWorkItemHandler("notificacao_lider",
emailHandler);
kSession.getWorkItemManager().registerWorkItemHandler("notificacao_negocio",
emailHandler);
kSession.getWorkItemManager().registerWorkItemHandler("notificacao_responsavel",
emailHandler);
kSession.getWorkItemManager().registerWorkItemHandler("modulo_orcamento",
orcamentoHandler);
kSession.getWorkItemManager().registerWorkItemHandler("muda_status",
mudarStatusHandler);
TaskClient client = new TaskClient(new
HornetQTaskClientConnector(UUID.randomUUID().toString(), new
HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
TaskManager taskManager = new TaskManager();
AsyncHornetQHTWorkItemHandler htHandler = new
AsyncHornetQHTWorkItemHandler(taskClient, kSession, true);
htHandler.setPort(5445);
htHandler.connect();
kSession.getWorkItemManager().registerWorkItemHandler("Human Task",
htHandler);
}
{code}
Anyone have any insight? I already searched the whole community, but nothing helped.
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/832169#832169]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]