NPE happens within custom WorkItemHandler after changing runtime strategy from Singleton to PerProcessInstance

Solution In Progress - Updated -

Issue

We had recently shifted from Container runtime strategy from 'Singleton' to 'Per process instance strategy' . After that change we are seeing NPE within custom WorkItemHander as follows.

2019-10-15 15:43:11,151 WARN  [org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager] (Thread-174) ProcessInstanceIdContext or CorrelationKeyContext shall be used when interacting with PerProcessInstance runtime manager
2019-10-15 15:43:11,180 ERROR [stderr] (Thread-174) Exception in thread "Thread-174" java.lang.NullPointerException
2019-10-15 15:43:11,180 ERROR [stderr] (Thread-174)     at com.redhat.gss.CustomRequestHandler.run(CustomRequestHandler.java:xx)
2019-10-15 15:43:11,180 ERROR [stderr] (Thread-174)     at java.lang.Thread.run(Thread.java:748)

Earlier to this change we are fetching the variables from process context (org.kie.api.runtime.process.ProcessContext) like the following and NPE happens when accessing to this variables .

...
                RuntimeManager manager = RuntimeManagerRegistry.get().getManager(deploymentId);
                RuntimeEngine runtimeEngine = manager.getRuntimeEngine(EmptyContext.get());
                KieSession ksession = runtimeEngine.getKieSession();
                WorkflowProcessInstanceImpl k = (WorkflowProcessInstanceImpl) ksession.getProcessInstance(processInstanceId);
                logger.info("Process Variables: {}", k.getVariables());
                Map<String,Object> variableNames = k.getVariables();
                logger.info("variableNames: {}", variableNames.toString());
...

When we shift the strategy back to SINGLETON, it works .
What is wrong and how should this be addressed?

Environment

  • Red Hat Process Automation Manager
    • 7.3.0

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