Attempting to execute multi-threaded application causes RuntimeException with error "Process instance 1[process_idl] is disconnected"

Solution Verified - Updated -

Issue

We experience issues with multi-threaded access (either due to EJB @Asynchronous calls or JMS/MDBs) to the jBPM runtime.

Here is a brief explanation of the execution flow in our application:

  • The following component periodically checks for new ProcessSignal items:
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
@Singleton
public class ProcessSignalController {

    @EJB
    private ProcessService p;

    @Schedule(hour = "*", minute = "*", second="*/30", persistent = false)
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public void releaseQueuedTasks() {
        List<ProcessSignal> list = selectProcessesToSignal();
        for (ProcessSignal signal : list) {
                p.releaseWorkItemAsync(signal.getBpmProcessId(), signal.getBpmWorkItemId());
        }
    }
  • ProcessServiceBean.releseWorkItemAsync method is annotated with @Asynchronous:
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    @Asynchronous
    public void releaseWorkItemAsync(final Long processInstanceId, final Long workItemId){
        try {
            final GenericCommand<?> release = new WorkItemReleaseCommand(workItemId);
            executeWorkItemCommand(processInstanceId, release);
        }
    }

    private void executeWorkItemCommand(final Long processInstanceId, final GenericCommand<?> command) {
        final KieSession ksession = fProcessService.getExistingSession(processInstanceId);
        final CommandBasedStatefulKnowledgeSession commandSession = (CommandBasedStatefulKnowledgeSession)ksession;
        final CommandService commandService = commandSession.getCommandService();
        commandService.execute(command);
        final int rules = ksession.fireAllRules();
    }
  • When this happens for more than one ProcessSignal item at a time, the call fails with the following exception:
09:52:30,298 INFO  [org.jboss.jca.core.connectionmanager.listener.TxConnectionListener] (EJB default - 6) IJ000311: Throwable from unregister connection: java.lang.IllegalStateException: Trying to return an unknown connection2! org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@4243a1dd
    at org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManagerImpl.unregisterConnection(CachedConnectionManagerImpl.java:347)
    at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener.connectionClosed(TxConnectionListener.java:371)
    at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.closeHandle(BaseWrapperManagedConnection.java:568)
    at org.jboss.jca.adapters.jdbc.WrappedConnection.close(WrappedConnection.java:264)

...
    at org.jbpm.persistence.JpaProcessPersistenceContext.findProcessInstanceInfo(JpaProcessPersistenceContext.java:48) [jbpm-persistence-jpa-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:117) [jbpm-persistence-jpa-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:273) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:269) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
...
    at org.jbpm.CustomWorkItemHandler.onRelease(CustomWorkItemHandler.java:63) [jbpm6-extension-1.0.0.jar:1.0.0]
  • As a result, the ProcessSignal items are not removed from the database, and on the next periodic invocation of the scheduled bean, the releasing of the tasks fails:
09:53:00,110 WARN  [org.drools.persistence.SingleSessionCommandService] (EJB default - 9) Could not commit session: org.jbpm.workflow.instance.WorkflowRuntimeException: [processl:2 - task:2] -- null
    at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:139) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:155) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:347) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:306) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.impl.ExtendedNodeInstanceImpl.triggerCompleted(ExtendedNodeInstanceImpl.java:44) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:290) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:269) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.node.WorkItemNodeInstance.triggerCompleted(WorkItemNodeInstance.java:279) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.node.WorkItemNodeInstance.workItemCompleted(WorkItemNodeInstance.java:341) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.node.WorkItemNodeInstance.signalEvent(WorkItemNodeInstance.java:317) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:404) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:134) [drools-persistence-jpa-6.0.3-redhat-7-BZ-1167280.jar:6.0.3-redhat-7-BZ-1167280]
    at org.jbpm.CustomWorkItemHandler.onRelease(CustomWorkItemHandler.java:63) [jbpm6-extension-1.0.0.jar:1.0.0]
...
Caused by: java.lang.NullPointerException
    at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalExecuteWorkItem(JPAWorkItemManager.java:46) [drools-persistence-jpa-6.0.3-redhat-7-BZ-1167280.jar:6.0.3-redhat-7-BZ-1167280]
    at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:128) [jbpm-flow-6.0.3-redhat-7.jar:6.0.3-redhat-7]
    ... 80 more

09:53:00,135 ERROR [org.jboss.as.ejb3.invocation] (EJB default - 9) JBAS014134: EJB Invocation failed on component ProcessBean for method ... javax.ejb.EJBException: org.jbpm.workflow.instance.WorkflowRuntimeException:  [processl:2 - task:2] -- null
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:165) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:250) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:344) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:216) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
...
Caused by: org.jbpm.workflow.instance.WorkflowRuntimeException: [processl:2 - task:2] -- null

Environment

  • Red Hat JBoss BPM Suite
    • 6.0.3

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In