<!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;">
    Re: ProcessContext Throwing NPE
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/roxy1987">Shobhit Tyagi</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/802738#802738">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Thomas,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I tried the code. but it didnt work. Its the same thing. Following is my process def : </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml">&#160; <span class="jive-xml-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span> 
<span class="jive-xml-tag"><span>&lt;definitions id="Definition"
targetNamespace="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools" target="_blank">http://www.jboss.org/drools</a><span>"
typeLanguage="</span><a class="jive-link-external-small" href="http://www.java.com/javaTypes" rel="nofollow" target="_blank">http://www.java.com/javaTypes</a><span>"
expressionLanguage="</span><a class="jive-link-external-small" href="http://www.mvel.org/2.0" rel="nofollow" target="_blank">http://www.mvel.org/2.0</a><span>"
xmlns="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/BPMN/20100524/MODEL" rel="nofollow" target="_blank">http://www.omg.org/spec/BPMN/20100524/MODEL</a><span>"
xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" rel="nofollow" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"
xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/BPMN/20100524/MODEL" rel="nofollow" target="_blank">http://www.omg.org/spec/BPMN/20100524/MODEL</a><span> BPMN20.xsd"
xmlns:g="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools/flow/gpd" target="_blank">http://www.jboss.org/drools/flow/gpd</a><span>"
xmlns:bpmndi="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/BPMN/20100524/DI" rel="nofollow" target="_blank">http://www.omg.org/spec/BPMN/20100524/DI</a><span>"
xmlns:dc="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/DD/20100524/DC" rel="nofollow" target="_blank">http://www.omg.org/spec/DD/20100524/DC</a><span>"
xmlns:di="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/DD/20100524/DI" rel="nofollow" target="_blank">http://www.omg.org/spec/DD/20100524/DI</a><span>"
xmlns:tns="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools" target="_blank">http://www.jboss.org/drools</a><span>"&gt;</span></span>

<span class="jive-xml-tag">&lt;itemDefinition id="_taskUserItem" structureRef="String" /&gt;</span>

<span class="jive-xml-tag">&lt;itemDefinition id="_2-taskUserItem" structureRef="String" /&gt;</span>

<span class="jive-xml-tag">&lt;itemDefinition id="_3-taskUserItem" structureRef="String" /&gt;</span>

<span class="jive-xml-tag">&lt;process processType="Private" isExecutable="true" id="com.sample.dynamicTaskVariable" name="Dynamic Task Variable Process" tns:packageName="defaultPackage" &gt;</span>

<span class="jive-xml-comment">&lt;!-- process variables --&gt;
<span class="jive-xml-tag">&lt;property id="taskUser" itemSubjectRef="_taskUserItem"/&gt;</span>

&lt;!-- nodes --&gt;
<span class="jive-xml-tag">&lt;startEvent id="_1" name="StartProcess" /&gt;</span>
<span class="jive-xml-tag">&lt;userTask id="_2" name="Create Variable" &gt;</span>
<span class="jive-xml-tag">&lt;ioSpecification&gt;</span>
<span class="jive-xml-tag">&lt;dataInput id="_2_TaskNameInput" name="TaskName" /&gt;</span>
<span class="jive-xml-tag">&lt;dataInput id="_2_CommentInput" name="Comment" /&gt;</span>
<span class="jive-xml-tag">&lt;dataOutput id="_2_taskVariableOutput" name="taskVariable" /&gt;</span>
<span class="jive-xml-tag">&lt;inputSet&gt;</span>
<span class="jive-xml-tag">&lt;dataInputRefs&gt;</span>_2_TaskNameInput<span class="jive-xml-tag">&lt;/dataInputRefs&gt;</span>
<span class="jive-xml-tag">&lt;dataInputRefs&gt;</span>_2_CommentInput<span class="jive-xml-tag">&lt;/dataInputRefs&gt;</span>
<span class="jive-xml-tag">&lt;/inputSet&gt;</span>
<span class="jive-xml-tag">&lt;outputSet&gt;</span>
<span class="jive-xml-tag">&lt;dataOutputRefs&gt;</span>_2_taskVariableOutput<span class="jive-xml-tag">&lt;/dataOutputRefs&gt;</span>
<span class="jive-xml-tag">&lt;/outputSet&gt;</span>
<span class="jive-xml-tag">&lt;/ioSpecification&gt;</span>
<span class="jive-xml-tag">&lt;dataInputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;targetRef&gt;</span>_2_TaskNameInput<span class="jive-xml-tag">&lt;/targetRef&gt;</span>
<span class="jive-xml-tag">&lt;assignment&gt;</span>
<span class="jive-xml-tag">&lt;from xsi:type="tFormalExpression"&gt;</span>Create Variable<span class="jive-xml-tag">&lt;/from&gt;</span>
<span class="jive-xml-tag">&lt;to xsi:type="tFormalExpression"&gt;</span>_2_TaskNameInput<span class="jive-xml-tag">&lt;/to&gt;</span>
<span class="jive-xml-tag">&lt;/assignment&gt;</span>
<span class="jive-xml-tag">&lt;/dataInputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;dataInputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;targetRef&gt;</span>_2_CommentInput<span class="jive-xml-tag">&lt;/targetRef&gt;</span>
<span class="jive-xml-tag">&lt;assignment&gt;</span>
<span class="jive-xml-tag">&lt;from xsi:type="tFormalExpression"&gt;</span>createVariable.xhtml<span class="jive-xml-tag">&lt;/from&gt;</span>
<span class="jive-xml-tag">&lt;to xsi:type="tFormalExpression"&gt;</span>_2_CommentInput<span class="jive-xml-tag">&lt;/to&gt;</span>
<span class="jive-xml-tag">&lt;/assignment&gt;</span>
<span class="jive-xml-tag">&lt;/dataInputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;dataOutputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;sourceRef&gt;</span>_2_taskVariableOutput<span class="jive-xml-tag">&lt;/sourceRef&gt;</span>
<span class="jive-xml-tag">&lt;targetRef&gt;</span>taskUser<span class="jive-xml-tag">&lt;/targetRef&gt;</span>
<span class="jive-xml-tag">&lt;/dataOutputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;potentialOwner&gt;</span>
<span class="jive-xml-tag">&lt;resourceAssignmentExpression&gt;</span>
<span class="jive-xml-tag">&lt;formalExpression&gt;</span>krisv<span class="jive-xml-tag">&lt;/formalExpression&gt;</span>
<span class="jive-xml-tag">&lt;/resourceAssignmentExpression&gt;</span>
<span class="jive-xml-tag">&lt;/potentialOwner&gt;</span>
<span class="jive-xml-tag">&lt;/userTask&gt;</span>
<span class="jive-xml-tag">&lt;userTask id="_3" name="Verify Variable" &gt;</span>
<span class="jive-xml-tag">&lt;ioSpecification&gt;</span>
<span class="jive-xml-tag">&lt;dataInput id="_3_TaskNameInput" name="TaskName" /&gt;</span>
<span class="jive-xml-tag">&lt;dataInput id="_3_CommentInput" name="Comment" /&gt;</span>
<span class="jive-xml-tag">&lt;inputSet&gt;</span>
<span class="jive-xml-tag">&lt;dataInputRefs&gt;</span>_3_TaskNameInput<span class="jive-xml-tag">&lt;/dataInputRefs&gt;</span>
<span class="jive-xml-tag">&lt;dataInputRefs&gt;</span>_3_CommentInput<span class="jive-xml-tag">&lt;/dataInputRefs&gt;</span>
<span class="jive-xml-tag">&lt;/inputSet&gt;</span>
<span class="jive-xml-tag">&lt;outputSet&gt;</span>
<span class="jive-xml-tag">&lt;/outputSet&gt;</span>
<span class="jive-xml-tag">&lt;/ioSpecification&gt;</span>
<span class="jive-xml-tag">&lt;dataInputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;targetRef&gt;</span>_3_TaskNameInput<span class="jive-xml-tag">&lt;/targetRef&gt;</span>
<span class="jive-xml-tag">&lt;assignment&gt;</span>
<span class="jive-xml-tag">&lt;from xsi:type="tFormalExpression"&gt;</span>Verify Variable<span class="jive-xml-tag">&lt;/from&gt;</span>
<span class="jive-xml-tag">&lt;to xsi:type="tFormalExpression"&gt;</span>_3_TaskNameInput<span class="jive-xml-tag">&lt;/to&gt;</span>
<span class="jive-xml-tag">&lt;/assignment&gt;</span>
<span class="jive-xml-tag">&lt;/dataInputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;dataInputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;targetRef&gt;</span>_3_CommentInput<span class="jive-xml-tag">&lt;/targetRef&gt;</span>
<span class="jive-xml-tag">&lt;assignment&gt;</span>
<span class="jive-xml-tag">&lt;from xsi:type="tFormalExpression"&gt;</span>verifyVariable.xhtml<span class="jive-xml-tag">&lt;/from&gt;</span>
<span class="jive-xml-tag">&lt;to xsi:type="tFormalExpression"&gt;</span>_3_CommentInput<span class="jive-xml-tag">&lt;/to&gt;</span>
<span class="jive-xml-tag">&lt;/assignment&gt;</span>
<span class="jive-xml-tag">&lt;/dataInputAssociation&gt;</span>
<span class="jive-xml-tag">&lt;potentialOwner&gt;</span>
<span class="jive-xml-tag">&lt;resourceAssignmentExpression&gt;</span>
<span class="jive-xml-tag">&lt;formalExpression&gt;</span>#{taskUser}<span class="jive-xml-tag">&lt;/formalExpression&gt;</span>
<span class="jive-xml-tag">&lt;/resourceAssignmentExpression&gt;</span>
<span class="jive-xml-tag">&lt;/potentialOwner&gt;</span>
<span class="jive-xml-tag">&lt;/userTask&gt;</span>
<span class="jive-xml-tag">&lt;endEvent id="_4" name="End" &gt;</span>
<span class="jive-xml-tag">&lt;terminateEventDefinition /&gt;</span>
<span class="jive-xml-tag">&lt;/endEvent&gt;</span>

&lt;!-- connections --&gt;</span>
<span class="jive-xml-tag">&lt;sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" /&gt;</span>
<span class="jive-xml-tag">&lt;sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" /&gt;</span>
<span class="jive-xml-tag">&lt;sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" /&gt;</span>

<span class="jive-xml-tag">&lt;/process&gt;</span>

<span class="jive-xml-tag">&lt;bpmndi:BPMNDiagram&gt;</span>
<span class="jive-xml-tag">&lt;bpmndi:BPMNPlane bpmnElement="com.sample.dynamicTaskVariable" &gt;</span>
<span class="jive-xml-tag">&lt;bpmndi:BPMNShape bpmnElement="_1" &gt;</span>
<span class="jive-xml-tag">&lt;dc:Bounds x="132" y="216" width="48" height="48" /&gt;</span>
<span class="jive-xml-tag">&lt;/bpmndi:BPMNShape&gt;</span>
<span class="jive-xml-tag">&lt;bpmndi:BPMNShape bpmnElement="_2" &gt;</span>
<span class="jive-xml-tag">&lt;dc:Bounds x="228" y="204" width="169" height="73" /&gt;</span>
<span class="jive-xml-tag">&lt;/bpmndi:BPMNShape&gt;</span>
<span class="jive-xml-tag">&lt;bpmndi:BPMNShape bpmnElement="_3" &gt;</span>
<span class="jive-xml-tag">&lt;dc:Bounds x="444" y="204" width="169" height="73" /&gt;</span>
<span class="jive-xml-tag">&lt;/bpmndi:BPMNShape&gt;</span>
<span class="jive-xml-tag">&lt;bpmndi:BPMNShape bpmnElement="_4" &gt;</span>
<span class="jive-xml-tag">&lt;dc:Bounds x="672" y="216" width="48" height="48" /&gt;</span>
<span class="jive-xml-tag">&lt;/bpmndi:BPMNShape&gt;</span>
<span class="jive-xml-tag">&lt;bpmndi:BPMNEdge bpmnElement="_1-_2" &gt;</span>
<span class="jive-xml-tag">&lt;di:waypoint x="156" y="240" /&gt;</span>
<span class="jive-xml-tag">&lt;di:waypoint x="312" y="240" /&gt;</span>
<span class="jive-xml-tag">&lt;/bpmndi:BPMNEdge&gt;</span>
<span class="jive-xml-tag">&lt;bpmndi:BPMNEdge bpmnElement="_2-_3" &gt;</span>
<span class="jive-xml-tag">&lt;di:waypoint x="312" y="240" /&gt;</span>
<span class="jive-xml-tag">&lt;di:waypoint x="528" y="240" /&gt;</span>
<span class="jive-xml-tag">&lt;/bpmndi:BPMNEdge&gt;</span>
<span class="jive-xml-tag">&lt;bpmndi:BPMNEdge bpmnElement="_3-_4" &gt;</span>
<span class="jive-xml-tag">&lt;di:waypoint x="528" y="240" /&gt;</span>
<span class="jive-xml-tag">&lt;di:waypoint x="696" y="240" /&gt;</span>
<span class="jive-xml-tag">&lt;/bpmndi:BPMNEdge&gt;</span>
<span class="jive-xml-tag">&lt;/bpmndi:BPMNPlane&gt;</span>
<span class="jive-xml-tag">&lt;/bpmndi:BPMNDiagram&gt;</span>

<span class="jive-xml-tag">&lt;/definitions&gt;</span>

</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Then I complete the task as following : </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>void</b></font> completeTask(<font color="navy"><b>long</b></font> taskId, String userId, Map&lt;String, Object&gt; map) <font color="navy"><b>throws</b></font> Exception
 <font color="navy">{</font>
&#160; String name = <font color="red">"client 1"</font>+UUID.randomUUID();
&#160; TaskClient client = <font color="navy"><b>new</b></font> TaskClient(<font color="navy"><b>new</b></font> HornetQTaskClientConnector(name, <font color="navy"><b>new</b></font> HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
&#160; BlockingTaskOperationResponseHandler responseHandler = <font color="navy"><b>new</b></font> BlockingTaskOperationResponseHandler();
&#160; ContentData contentData = <font color="navy"><b>null</b></font>;
&#160; client.connect(ipAddress, port);
&#160; <font color="navy"><b>try</b></font>
&#160; <font color="navy">{</font>
&#160;&#160; contentData = ContentMarshallerHelper.marshal(map, <font color="navy"><b>null</b></font>);
&#160;&#160; client.complete(taskId, userId, contentData, responseHandler);
&#160;&#160; responseHandler.waitTillDone(5000);
&#160;&#160; BpmAPI.completeWorkItem(taskId);
&#160; <font color="navy">}</font>
&#160; <font color="navy"><b>catch</b></font>(Exception e)
&#160; <font color="navy">{</font>
&#160;&#160; BpmExceptionHandler.handleException(e);
&#160; <font color="navy">}</font>
&#160; <font color="navy"><b>finally</b></font>
&#160; <font color="navy">{</font>
&#160;&#160; <font color="navy"><b>if</b></font>(client != <font color="navy"><b>null</b></font>)
&#160;&#160; <font color="navy">{</font>
&#160;&#160;&#160; client.disconnect();
&#160;&#160; <font color="navy">}</font> 
&#160; <font color="navy">}</font>
 <font color="navy">}</font>
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In the map above I put a variable for next task. </p><p>Only difference in the code is that I complete the task and then I complete the work item.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Regards.</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/802738#802738">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>