-
1. Re: createProcessInstance + startProcessInstance does not update processinstanceinfo state
rudi_fisher Apr 26, 2012 9:47 AM (in response to affandar)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.
Solution:
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.
env.set(EnvironmentName.TRANSACTION_MANAGER, transactionManager);
Working for me correctly now.
-
2. Re: createProcessInstance + startProcessInstance does not update processinstanceinfo state
affandar Apr 26, 2012 12:33 PM (in response to rudi_fisher)Yes that was exactly my problem as well. Now I feel guilty for not updating this thread when I found the issue
Thanks!