JBPM6 Spring Persistence and Runtime Manager
herwix Aug 21, 2013 4:52 PMHey guys,
I have been trying to integrate JBPM6 in my Spring-Hibernate based Grails application, but it seems that I'm stuck and maybe you guys here could point me in the right direction.
I am trying to get the RuntimeManager working with a local spring transaction scheme. I have tried a lot of stuff but can't seem to find the right approach.
I have set up a EntityManagerFactory bean, which loads the persistence-unit org.jbpm.presistence.jpa (with transaction-type "Resource_local") with the org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.
I have also set up a org.springframework.orm.jpa.JpaTransactionManager bean.
When I now try to get a runtimeEngine via the RuntimeEnvironmentBuilder:
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefaultInMemory() .userGroupCallback(getUserGroupCallback()) .entityManagerFactory(entityManagerFactory) .registerableItemsFactory(new KModuleRegisterableItemsFactory(kcontainer,'')) .addEnvironmentEntry(EnvironmentName.TRANSACTION_MANAGER,jbpmTransactionManager) .get(); RuntimeManager manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment); RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
I get the following error:
NamingException occurred when processing request: [GET] /bpm/test/ Cannot create resource instance. Stacktrace follows: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:116) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321) at org.apache.naming.NamingContext.lookup(NamingContext.java:843) at org.apache.naming.NamingContext.lookup(NamingContext.java:154) at org.apache.naming.NamingContext.lookup(NamingContext.java:831) at org.apache.naming.NamingContext.lookup(NamingContext.java:168) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158) at javax.naming.InitialContext.lookup(InitialContext.java:411) at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:122) at org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:69) at org.jbpm.shared.services.impl.JbpmJTATransactionManager.<init>(JbpmJTATransactionManager.java:39) at org.jbpm.runtime.manager.impl.factory.LocalTaskServiceFactory.newTaskService(LocalTaskServiceFactory.java:48) at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager.getRuntimeEngine(PerProcessInstanceRuntimeManager.java:94) at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager.init(PerProcessInstanceRuntimeManager.java:258) at org.jbpm.runtime.manager.impl.RuntimeManagerFactoryImpl.newPerProcessInstanceRuntimeManager(RuntimeManagerFactoryImpl.java:103) at org.jbpm.runtime.manager.impl.RuntimeManagerFactoryImpl.newPerProcessInstanceRuntimeManager(RuntimeManagerFactoryImpl.java:94) at bpm.TestController$$EOFBIT6u.index(TestController.groovy:82) at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:200) at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722)
Looking at the stacktrace I found the the LocalTaskServiceFactory where the documentation says:
/**
* Regular <code>TaskServiceFactory</code> implementation that shall be used for non CDI environments.
* Creates new <code>TaskService</code> instance for every call to the factory.
* <code>TaskService</code> instance will be equipped with <code>JbpmJTATransactionManager</code>
* for transaction management, this is mandatory as it must participate in already active
* transaction if such exists.
*/
So it seems it's not possible to use the RuntimeManager without a JTA Transaction Manager? I thought it might be possible to supply the localTransactionManager via the Environment? But I am fishing in the dark.
If I am totally off the mark here in what I am doing, I would appreciate any pointer into the recommended way to integrate jbpm6 (and especially the runtime manager) into a spring-hibernate based application. I have looked at kie-spring, but there is little jbpm specific stuff.
Cheers, Alex