Invalid session was used for this context org.kie.internal.runtime.manager.context.ProcessInstanceIdContext when getProcessInstance with correlationKey with PerProcessInstanceRuntimeManager in BPM

Solution Unverified - Updated -

Issue

  • I get the following Exception when I tried to get a ProcessInstacnce with a correlation key with PerProcessInstanceRuntimeManager.
14:33:57,445 WARN  [org.drools.persistence.SingleSessionCommandService] (http-localhost.localdomain/127.0.0.1:8080-1) Could not commit session: java.lang.IllegalStateException: Invalid session was used for this context org.kie.internal.runtime.manager.context.ProcessInstanceIdContext@457ce57c
    at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager.validate(PerProcessInstanceRuntimeManager.java:140) [jbpm-runtime-manager-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:89) [jbpm-persistence-jpa-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:83) [jbpm-persistence-jpa-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:194) [jbpm-persistence-jpa-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:237) [jbpm-flow-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.core.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1612) [drools-core-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:936) [drools-core-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.core.command.runtime.process.GetProcessInstanceByCorrelationKeyCommand.execute(GetProcessInstanceByCorrelationKeyCommand.java:58) [drools-core-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.core.command.runtime.process.GetProcessInstanceByCorrelationKeyCommand.execute(GetProcessInstanceByCorrelationKeyCommand.java:32) [drools-core-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.core.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36) [drools-core-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.core.command.impl.AbstractInterceptor.executeNext(AbstractInterceptor.java:41) [drools-core-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.persistence.SingleSessionCommandService$TransactionInterceptor.execute(SingleSessionCommandService.java:533) [drools-persistence-jpa-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.core.command.impl.AbstractInterceptor.executeNext(AbstractInterceptor.java:41) [drools-core-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.persistence.jpa.OptimisticLockRetryInterceptor.execute(OptimisticLockRetryInterceptor.java:73) [drools-persistence-jpa-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:377) [drools-persistence-jpa-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstance(CommandBasedStatefulKnowledgeSession.java:551) [drools-core-6.0.3-redhat-4.jar:6.0.3-redhat-4]
    at org.jbpm.examples.ejb.JbpmService.getProcessInstance(JbpmService.java:67) [classes:]
...

Sorce code:

CorrelationKeyFactory factory = KieInternalServices.Factory.get().newCorrelationKeyFactory();
CorrelationKey correlationKey = factory.newCorrelationKey(businessKey);
RuntimeEngine runtime = runtimeManager.getRuntimeEngine(CorrelationKeyContext.get());
KieSession ksession = runtime.getKieSession();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)ksession).getProcessInstance(correlationKey);

Environment

  • Red Hat JBoss BPM Suite
    • 6.0.2

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