I have a problem which I think is similar to these but my scenario is slightly different.
How to make a process instance go on with jBPM5?
Human task API, how to move forward in the workflow ?
Here is my problem. I create a process using the following:
Environment env = KnowledgeBaseFactory.newEnvironment();
InitialContext ctx = new InitialContext();
UserTransaction transactionManager = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
StatefulKnowledgeSession knowledgeSession = JPAKnowledgeService.newStatefulKnowledgeSession(knowledgeBase, null, env);
WorkItemHandler handler = new CommandBasedWSHumanTaskHandler(knowledgeSession);
knowledgeSession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
statefulSession.dispose(); (Remember this line)
This works fine. The process is created and the first Human Task exists as expected.
My next step is to use the Mina Task Client, via the task client to assign and complete the task. The assign works perfectly however I get the following exception when completing the task.
SEVERE: Could not commit session
This results in the task being completed but the next task is not created.
This exception is thrown because the org.drools.persistence.jpa.JpaPersistenceContextManager.appScopedEntityManager is null. This field is initialised when the JpaPersistenceContextManager is created and is nulled when the dispose method is called.
I was able to have the task complete properly by commenting out the call to dispose.
Not a good solution. I can't keep sessions open forever.
The crux of the problem is that when completing the task it attempts to use the JpaPersistenceContextManager that was used to create the process, which has already been disposed of.
My question is, how do I re-intitialise the JpaPersistenceContextManager to use ensure it has an active entityManager? Remember I'm making a call via the Mina Task Client so have no access to the JpaPersistenceContextManager.
Any help would be really appreciated.