<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Calling workItemManager.completeWorkItem() on a dynamicSubProcess results in NPE & root cause
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/joe.chuah">Wooi Joe Chuah</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/779240#779240">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've been bugged by this stack trace for a long time now whenever a dynamicSubProcess created by the DynamicUtils is terminated.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Caused by: java.lang.NullPointerException</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.SubProcessNodeInstance.handleOutMappings(SubProcessNodeInstance.java:192)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.SubProcessNodeInstance.processInstanceCompleted(SubProcessNodeInstance.java:185)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.SubProcessNodeInstance.signalEvent(SubProcessNodeInstance.java:173)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:344)</p><p>&#160;&#160;&#160; at org.jbpm.process.instance.event.DefaultSignalManager.internalSignalEvent(DefaultSignalManager.java:81)</p><p>&#160;&#160;&#160; at org.jbpm.process.instance.event.DefaultSignalManager$SignalAction.execute(DefaultSignalManager.java:181)</p><p>&#160;&#160;&#160; at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:976)</p><p>&#160;&#160;&#160; ... 96 more</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>After tracing the code, I've found the root cause which is located at org.jbpm.workflow.core.node.SubProcessNode</p><p>public List&lt;DataAssociation&gt; getOutAssociations() {</p><p>&#160;&#160;&#160; return Collections.unmodifiableList(this.outMapping); }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>the outMapping attribute of the dynamicSubProcess is null hence calling Collections.unmodifiableList(<em>null</em>) will hit a NPE.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Since SubProcessNodeInstance.java:192 (handleOutMappings) expects a Collection object to be returned, I suggest returning an empty list if the outMapping is null.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If anyone would be so helpful to implement a fix for this I'd be very greatful <span> :) </span> no more ugly stacktraces after completing the process.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/779240#779240">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>