1 Reply Latest reply on Nov 30, 2012 4:17 AM by Maciej Swiderski

    Calling workItemManager.completeWorkItem() on a dynamicSubProcess results in NPE & root cause

    Wooi Joe Chuah Newbie

      Hi,

       

      I've been bugged by this stack trace for a long time now whenever a dynamicSubProcess created by the DynamicUtils is terminated.

       

      Caused by: java.lang.NullPointerException

          at org.jbpm.workflow.instance.node.SubProcessNodeInstance.handleOutMappings(SubProcessNodeInstance.java:192)

          at org.jbpm.workflow.instance.node.SubProcessNodeInstance.processInstanceCompleted(SubProcessNodeInstance.java:185)

          at org.jbpm.workflow.instance.node.SubProcessNodeInstance.signalEvent(SubProcessNodeInstance.java:173)

          at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:344)

          at org.jbpm.process.instance.event.DefaultSignalManager.internalSignalEvent(DefaultSignalManager.java:81)

          at org.jbpm.process.instance.event.DefaultSignalManager$SignalAction.execute(DefaultSignalManager.java:181)

          at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:976)

          ... 96 more

       

      After tracing the code, I've found the root cause which is located at org.jbpm.workflow.core.node.SubProcessNode

      public List<DataAssociation> getOutAssociations() {

          return Collections.unmodifiableList(this.outMapping); }

       

      the outMapping attribute of the dynamicSubProcess is null hence calling Collections.unmodifiableList(null) will hit a NPE.

       

      Since SubProcessNodeInstance.java:192 (handleOutMappings) expects a Collection object to be returned, I suggest returning an empty list if the outMapping is null.

       

      If anyone would be so helpful to implement a fix for this I'd be very greatful no more ugly stacktraces after completing the process.

       

      Thanks