How to get KieSession for a process launched from jbpm-console
ghollins Jan 2, 2014 4:58 PMHi,
I'm using jbpm 6.0.0.Final, and I have set it up to use a custom WorkItemHandler (by creating my own handlers JAR and putting it in WEB-INF/lib). My custom WorkItemHandler gets called as expected when I launch a process from jbpm-console. However, I'm having trouble getting a hold of the KieSession associated with the process from within the WorkItemHandler.
I've tried several approaches so far.
Attempt #1:
(see http://stackoverflow.com/questions/20862350/accessing-kiesession-from-jbpm6-workitemhandler)
Attempt #2:
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().get();
RuntimeManager manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
RuntimeEngine runtimeEngine = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtimeEngine.getKieSession();
This results in:
13:46:22,149 ERROR [builtin.jbpm.JbpmTask] (http-localhost-127.0.0.1-8080-3) problem getting processInstance: javax.persistence.PersistenceException: No Persistence provider for EntityManager named org.jbpm.persistence.jpa
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at org.jbpm.runtime.manager.impl.DefaultRuntimeEnvironment.init(DefaultRuntimeEnvironment.java:72) [jbpm-runtime-manager-6.0.0.Final.jar:6.0.0.Final]
at org.jbpm.runtime.manager.impl.RuntimeEnvironmentBuilder.get(RuntimeEnvironmentBuilder.java:314) [jbpm-runtime-manager-6.0.0.Final.jar:6.0.0.Final]
at org.jbpm.runtime.manager.impl.RuntimeEnvironmentBuilder.get(RuntimeEnvironmentBuilder.java:56) [jbpm-runtime-manager-6.0.0.Final.jar:6.0.0.Final]
...
This error is thrown from this line:
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().get();
I'm using the out-of-the-box full installer, and therefore it's using H2.
I know there must be a KieSession. I just want to re-use this existing one, and NOT create a new one. My question is just "How do I get access to it?"
Thanks!