I am seeing a strange issue in my jbpm 5 + hibernate + mysql configuration.
A test process 'com.sample.bpmn' consists of the following: start -> myactivityhandler -> somescript -> end
myactivityhandler is an async activity handler and hence 'execute' returns without calling completeWorkItem.
Now after execution of the following snippet:
I look at the ProcessInstanceInfo for the process and I see that the instance state is rightful set to ACTIVE since the process is actually active and just hit its first savepoint after the myactivityhandler.
However if I break the startprocess down to the following:
ProcessInstance pi = ksession.createProcessInstance("com.sample.bpmn", null);
After execution of the above two, I expect the state would be the same as the previous snippet i.e. process instance state == ACTIVE but in reality it is set to PENDING. Also when I trace the SQL that hibernate is sending to MySQL I don't see any UPDATE going to the ProcessInstanceInfo table. This is a problem since now I can't complete the myactivityhandler workitem to continue the process.. and it needs to be started again.
Any clue why the above two scenarios are behaving differently?
Fwiw, if I configure the system to use the in-memory H2 then everything works fine and dandy.
A had a similar problem.
My setup is: JBPM 5.2.0 + JPA + Hibernate + java:jboss/TransactionManager + MSSQL + JBoss AS 7
I'm using WI handlers in similar way - some are synchronous and some are asynchronous, but state of process wasn't persisted correctly in save points (at the end of execution of WI handler). I found that my transaction manager didn't work correctly and all process instances stay all the time in memmory and wasn't loaded/inserted into DB. Problem was that my transaction manager wasn't added into Environment.
You can easy forget for this very important step in your code. Everything seems working correctly if you are not restarting jBPM and you don't need any recovery utility. I was looking into manual about transactions here: http://docs.jboss.org/jbpm/v5.2/userguide/ch07.html#d0e2914 I also read source code of jbpm-gwt-console (class CommandDelegate) but there is now direct description how to configure and use JBoss transaction manager. Maybe small update of manual should by helpfull.
Maybe this help someone with similar issue. Correct codes:
Configuration of transaction manager for JBoss AS 7 in persistence.xml:
<property name="hibernate.transaction.manager_lookup_class" value="org.jbpm.integration.console.JBPMTransactionManager" />
Do not forget for this during initialization of your sessions, environment ... for example:
// get transaction manager from hibernate configuration (see persistence.xml)
TransactionManagerLookup transactionManagerLookup = ((SessionFactoryImplementor)((HibernateEntityManagerFactory)emf).getSessionFactory()).getSettings().getTransactionManagerLookup();
TransactionManager transactionManager = transactionManagerLookup.getTransactionManager(null);
// this is very important step to add transactionManager into env. Else transaction manager will not be initialized correctly for jbpm.
Working for me correctly now.