Starting a process from a script task of another process causes NullPointerException

Solution Unverified - Updated -

Issue

  • The following exception takes place during the execution of a process instance and it persists until server restart. To be precise the issue occurs when creating other process instance from inside a script task of a running process instance's flow.
2015-03-13 11:04:31,154 ERROR [org.drools.persistence.SingleSessionCommandService] (http-127.0.0.1-8080-310) Could not commit session
java.lang.RuntimeException: unable to execute Action
    at org.jbpm.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:49)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:210)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:169)
    at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)
    at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
    at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)
    at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:188)
    at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:305)
    at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:169)
    at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:139)
    at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1075)
    at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:322)
    at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:119)
    at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:38)
    at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)
    at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:365)
    at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:229)
    at org.jbpm.integration.console.CommandDelegate.startProcess(CommandDelegate.java:120)
    at org.jbpm.integration.console.ProcessManagement.newInstance(ProcessManagement.java:88)
    at org.jboss.bpm.console.server.FormProcessingFacade.startProcessWithUI(FormProcessingFacade.java:197)
    ...
Caused by: java.lang.NullPointerException
    at org.jbpm.process.instance.impl.ProcessInstanceImpl.setProcess(ProcessInstanceImpl.java:61)
    at org.jbpm.marshalling.impl.AbstractProtobufProcessInstanceMarshaller.readProcessInstance(AbstractProtobufProcessInstanceMarshaller.java:375)
    at org.jbpm.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:149)
    at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:89)
    at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:209)
    at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:205)
    at org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1093)
    at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:295)
    ...

Below code is used to create the processes from inside the script task.

     String processToStart = "abc.xyz";

     java.util.Map<String, Object> procVariableMap = new java.util.HashMap<String, Object>();
     procVariableMap.put("FirstVar", "Val1");
     procVariableMap.put("SecondVar", "Val2");

     org.drools.runtime.process.ProcessInstance instanceOne = kcontext.getKnowledgeRuntime().startProcess(processToStart, procVariableMap);
...
  • Looking at the stack trace it appears that the AbstractProtobufProcessInstanceMarshaller is using an InternalRuleBase object from MarshallerReaderContext. By all account, it seems that the InternalRuleBase object case is returning null objects. The implementation of that interface is a class called ReteooRuleBase which extends a class called AbstractRuleBase. That class defines a method getProcess(String id) and the implementation of that method relies on an internal map called processes. Could it be that there is issue with the maps from time to time which leads to the above problem?

  • Anyway, what are the implications involved in calling a process from inside script task of another process ? Is this an efficient way of starting a new process ?

  • Should users clean up the ksession afterwards using ksession.dispose(), or is that taken care of?

Environment

  • Red Hat JBoss BRMS (BRMS)
    • 5.3.1

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
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.