Single TaskService and multiple RuntimeManager non CDI
herwix Nov 3, 2013 9:04 AMHey guys,
I have a situation where I would like to use multiple runtimeManager in my app, but provide a unified TaskList to my users.
As I understand it now, this is done in the CDI based runtimeManager through the injection of a single taskService to all runtimeManagers, but I might be wrong?!
I have tried to emulate that behavior in my code, e.g. I prepare a single taskService (normal HumanTaskServiceFactory.newTaskServiceConfigurator configured with JbpmJTATransactionManager, my entityManagerFactory and customUsergroupCallback) and inject the same object into all my runtimeManagers (or engines) - similar in spirit to the CDITaskServiceFactory.
This seems to work for some part:
I can create multiple runtimeManagers (or engines) and start and complete humanTasks from the single taskService object and the Events get picked up by the runtimeEngines (e.g. the process moves forward on completion of tasks).
However, when I run a Test based on the HumanTask Process from the jbpm6 runtime manager examples (https://github.com/mswiderski/jbpm-examples/blob/master/jbpm6/jbpm-sample/src/main/resources/humanTask.bpmn) I get a NPE - only if I have my taskservice injected into multiple runtimeEngines (e.g. I start the process twice in a perProcessInstance runtimeManager) - after I complete the last Task with the following trace:
2013-11-03 13:06:17,533 [main] DEBUG wih.ExternalTaskEventListener - >> I've recieved an event for a known session (3) ### REPORT - ### ### approval_document: null ### approval_translatedDocument: null ### approval_reviewComment: null 2013-11-03 13:06:17,548 [main] DEBUG tx.ExtendedJTATransactionManager - JTA TransactionManager found at fallback JNDI location [java:comp/TransactionManager] 2013-11-03 13:06:17,549 [main] DEBUG tx.ExtendedJTATransactionManager - JTA 1.1 [javax.transaction.TransactionSynchronizationRegistry] API not available 2013-11-03 13:06:17,549 [main] DEBUG tx.ExtendedJTATransactionManager - JTA TransactionManager found at fallback JNDI location [java:comp/TransactionManager] 2013-11-03 13:06:17,549 [main] DEBUG tx.ExtendedJTATransactionManager - JTA 1.1 [javax.transaction.TransactionSynchronizationRegistry] API not available 2013-11-03 13:06:17,560 [main] DEBUG persistence.SingleSessionCommandService - Instantiating JtaTransactionManager 2013-11-03 13:06:17,561 [main] DEBUG jta.JtaTransactionManager - JTA TransactionManager found at fallback JNDI location [java:comp/TransactionManager] 2013-11-03 13:06:17,561 [main] DEBUG jta.JtaTransactionManager - JTA 1.1 [javax.transaction.TransactionSynchronizationRegistry] API not available 2013-11-03 13:06:17,572 [main] DEBUG tx.ExtendedJTATransactionManager - JTA TransactionManager found at fallback JNDI location [java:comp/TransactionManager] 2013-11-03 13:06:17,572 [main] DEBUG tx.ExtendedJTATransactionManager - JTA 1.1 [javax.transaction.TransactionSynchronizationRegistry] API not available 2013-11-03 13:06:17,572 [main] DEBUG tx.ExtendedJTATransactionManager - JTA TransactionManager found at fallback JNDI location [java:comp/TransactionManager] 2013-11-03 13:06:17,572 [main] DEBUG tx.ExtendedJTATransactionManager - JTA 1.1 [javax.transaction.TransactionSynchronizationRegistry] API not available 2013-11-03 13:06:17,573 [main] DEBUG wih.ExternalTaskEventListener - >> I've recieved an event for a known session (3) 2013-11-03 13:06:17,600 [main] WARN persistence.SingleSessionCommandService - Could not commit session Message: null Line | Method ->> 106 | <init> in java.io.ByteArrayInputStream - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 105 | getWorkItem in org.drools.persistence.info.WorkItemInfo | 203 | internalGetWorkItem . . in org.drools.persistence.jpa.processinstance.JPAWorkItemManager | 130 | completeWorkItem in '' | 74 | execute . . . . . . . . in org.drools.core.command.runtime.process.CompleteWorkItemCommand | 35 | execute in '' | 36 | execute . . . . . . . . in org.drools.core.command.impl.DefaultCommandService | 41 | executeNext in org.drools.core.command.impl.AbstractInterceptor | 564 | execute . . . . . . . . in org.drools.persistence.SingleSessionCommandService$TransactionInterceptor | 41 | executeNext in org.drools.core.command.impl.AbstractInterceptor | 71 | execute . . . . . . . . in org.drools.persistence.jpa.OptimisticLockRetryInterceptor | 388 | execute in org.drools.persistence.SingleSessionCommandService | 145 | completeWorkItem . . . in org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession$1 | 102 | processTaskState in org.jbpm.services.task.wih.ExternalTaskEventListener | 143 | afterTaskCompletedEvent in '' | 74 | fire in org.jbpm.shared.services.impl.events.JbpmServicesEventImpl | 397 | taskOperation . . . . . in org.jbpm.services.task.internals.lifecycle.MVELLifeCycleManager | 47 | taskOperation in org.jbpm.services.task.identity.UserGroupLifeCycleManagerDecorator | 150 | complete . . . . . . . in org.jbpm.services.task.impl.TaskInstanceServiceImpl | 97 | complete in org.jbpm.services.task.identity.UserGroupTaskInstanceServiceDecorator | 102 | complete . . . . . . . in org.jbpm.services.task.subtask.SubTaskDecorator | 113 | complete in org.jbpm.services.task.deadlines.DeadlinesDecorator | 253 | complete . . . . . . . in org.jbpm.services.task.impl.TaskServiceEntryPointImpl
It seems that closing/completing the processInstance causes this NPE as the script node after the last HumanTask node gets executed fine... (see output from line 1 to 6 in the pasted log)
I can get this to work if I use a new TaskService for every runtimeEngine, but then I also need that specific taskService instance to move the process forward, as a signal from another taskService doesn't reach the correct runtimeEngine. And this doesn't really allow me to have a single unified tasklist for my users.
So what would be the preferred or best approach in this situation? Is this just a bug or did I miss something important?
Cheers, Alex
P.S. I use jbpm 6.CR4 at the moment