<!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;"> </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;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml">  <span class="jive-xml-tag"><?xml version="1.0" encoding="UTF-8"?></span>
<span class="jive-xml-tag"><span><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>"></span></span>
<span class="jive-xml-tag"><itemDefinition id="_taskUserItem" structureRef="String" /></span>
<span class="jive-xml-tag"><itemDefinition id="_2-taskUserItem" structureRef="String" /></span>
<span class="jive-xml-tag"><itemDefinition id="_3-taskUserItem" structureRef="String" /></span>
<span class="jive-xml-tag"><process processType="Private" isExecutable="true" id="com.sample.dynamicTaskVariable" name="Dynamic Task Variable Process" tns:packageName="defaultPackage" ></span>
<span class="jive-xml-comment"><!-- process variables -->
<span class="jive-xml-tag"><property id="taskUser" itemSubjectRef="_taskUserItem"/></span>
<!-- nodes -->
<span class="jive-xml-tag"><startEvent id="_1" name="StartProcess" /></span>
<span class="jive-xml-tag"><userTask id="_2" name="Create Variable" ></span>
<span class="jive-xml-tag"><ioSpecification></span>
<span class="jive-xml-tag"><dataInput id="_2_TaskNameInput" name="TaskName" /></span>
<span class="jive-xml-tag"><dataInput id="_2_CommentInput" name="Comment" /></span>
<span class="jive-xml-tag"><dataOutput id="_2_taskVariableOutput" name="taskVariable" /></span>
<span class="jive-xml-tag"><inputSet></span>
<span class="jive-xml-tag"><dataInputRefs></span>_2_TaskNameInput<span class="jive-xml-tag"></dataInputRefs></span>
<span class="jive-xml-tag"><dataInputRefs></span>_2_CommentInput<span class="jive-xml-tag"></dataInputRefs></span>
<span class="jive-xml-tag"></inputSet></span>
<span class="jive-xml-tag"><outputSet></span>
<span class="jive-xml-tag"><dataOutputRefs></span>_2_taskVariableOutput<span class="jive-xml-tag"></dataOutputRefs></span>
<span class="jive-xml-tag"></outputSet></span>
<span class="jive-xml-tag"></ioSpecification></span>
<span class="jive-xml-tag"><dataInputAssociation></span>
<span class="jive-xml-tag"><targetRef></span>_2_TaskNameInput<span class="jive-xml-tag"></targetRef></span>
<span class="jive-xml-tag"><assignment></span>
<span class="jive-xml-tag"><from xsi:type="tFormalExpression"></span>Create Variable<span class="jive-xml-tag"></from></span>
<span class="jive-xml-tag"><to xsi:type="tFormalExpression"></span>_2_TaskNameInput<span class="jive-xml-tag"></to></span>
<span class="jive-xml-tag"></assignment></span>
<span class="jive-xml-tag"></dataInputAssociation></span>
<span class="jive-xml-tag"><dataInputAssociation></span>
<span class="jive-xml-tag"><targetRef></span>_2_CommentInput<span class="jive-xml-tag"></targetRef></span>
<span class="jive-xml-tag"><assignment></span>
<span class="jive-xml-tag"><from xsi:type="tFormalExpression"></span>createVariable.xhtml<span class="jive-xml-tag"></from></span>
<span class="jive-xml-tag"><to xsi:type="tFormalExpression"></span>_2_CommentInput<span class="jive-xml-tag"></to></span>
<span class="jive-xml-tag"></assignment></span>
<span class="jive-xml-tag"></dataInputAssociation></span>
<span class="jive-xml-tag"><dataOutputAssociation></span>
<span class="jive-xml-tag"><sourceRef></span>_2_taskVariableOutput<span class="jive-xml-tag"></sourceRef></span>
<span class="jive-xml-tag"><targetRef></span>taskUser<span class="jive-xml-tag"></targetRef></span>
<span class="jive-xml-tag"></dataOutputAssociation></span>
<span class="jive-xml-tag"><potentialOwner></span>
<span class="jive-xml-tag"><resourceAssignmentExpression></span>
<span class="jive-xml-tag"><formalExpression></span>krisv<span class="jive-xml-tag"></formalExpression></span>
<span class="jive-xml-tag"></resourceAssignmentExpression></span>
<span class="jive-xml-tag"></potentialOwner></span>
<span class="jive-xml-tag"></userTask></span>
<span class="jive-xml-tag"><userTask id="_3" name="Verify Variable" ></span>
<span class="jive-xml-tag"><ioSpecification></span>
<span class="jive-xml-tag"><dataInput id="_3_TaskNameInput" name="TaskName" /></span>
<span class="jive-xml-tag"><dataInput id="_3_CommentInput" name="Comment" /></span>
<span class="jive-xml-tag"><inputSet></span>
<span class="jive-xml-tag"><dataInputRefs></span>_3_TaskNameInput<span class="jive-xml-tag"></dataInputRefs></span>
<span class="jive-xml-tag"><dataInputRefs></span>_3_CommentInput<span class="jive-xml-tag"></dataInputRefs></span>
<span class="jive-xml-tag"></inputSet></span>
<span class="jive-xml-tag"><outputSet></span>
<span class="jive-xml-tag"></outputSet></span>
<span class="jive-xml-tag"></ioSpecification></span>
<span class="jive-xml-tag"><dataInputAssociation></span>
<span class="jive-xml-tag"><targetRef></span>_3_TaskNameInput<span class="jive-xml-tag"></targetRef></span>
<span class="jive-xml-tag"><assignment></span>
<span class="jive-xml-tag"><from xsi:type="tFormalExpression"></span>Verify Variable<span class="jive-xml-tag"></from></span>
<span class="jive-xml-tag"><to xsi:type="tFormalExpression"></span>_3_TaskNameInput<span class="jive-xml-tag"></to></span>
<span class="jive-xml-tag"></assignment></span>
<span class="jive-xml-tag"></dataInputAssociation></span>
<span class="jive-xml-tag"><dataInputAssociation></span>
<span class="jive-xml-tag"><targetRef></span>_3_CommentInput<span class="jive-xml-tag"></targetRef></span>
<span class="jive-xml-tag"><assignment></span>
<span class="jive-xml-tag"><from xsi:type="tFormalExpression"></span>verifyVariable.xhtml<span class="jive-xml-tag"></from></span>
<span class="jive-xml-tag"><to xsi:type="tFormalExpression"></span>_3_CommentInput<span class="jive-xml-tag"></to></span>
<span class="jive-xml-tag"></assignment></span>
<span class="jive-xml-tag"></dataInputAssociation></span>
<span class="jive-xml-tag"><potentialOwner></span>
<span class="jive-xml-tag"><resourceAssignmentExpression></span>
<span class="jive-xml-tag"><formalExpression></span>#{taskUser}<span class="jive-xml-tag"></formalExpression></span>
<span class="jive-xml-tag"></resourceAssignmentExpression></span>
<span class="jive-xml-tag"></potentialOwner></span>
<span class="jive-xml-tag"></userTask></span>
<span class="jive-xml-tag"><endEvent id="_4" name="End" ></span>
<span class="jive-xml-tag"><terminateEventDefinition /></span>
<span class="jive-xml-tag"></endEvent></span>
<!-- connections --></span>
<span class="jive-xml-tag"><sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" /></span>
<span class="jive-xml-tag"><sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" /></span>
<span class="jive-xml-tag"><sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" /></span>
<span class="jive-xml-tag"></process></span>
<span class="jive-xml-tag"><bpmndi:BPMNDiagram></span>
<span class="jive-xml-tag"><bpmndi:BPMNPlane bpmnElement="com.sample.dynamicTaskVariable" ></span>
<span class="jive-xml-tag"><bpmndi:BPMNShape bpmnElement="_1" ></span>
<span class="jive-xml-tag"><dc:Bounds x="132" y="216" width="48" height="48" /></span>
<span class="jive-xml-tag"></bpmndi:BPMNShape></span>
<span class="jive-xml-tag"><bpmndi:BPMNShape bpmnElement="_2" ></span>
<span class="jive-xml-tag"><dc:Bounds x="228" y="204" width="169" height="73" /></span>
<span class="jive-xml-tag"></bpmndi:BPMNShape></span>
<span class="jive-xml-tag"><bpmndi:BPMNShape bpmnElement="_3" ></span>
<span class="jive-xml-tag"><dc:Bounds x="444" y="204" width="169" height="73" /></span>
<span class="jive-xml-tag"></bpmndi:BPMNShape></span>
<span class="jive-xml-tag"><bpmndi:BPMNShape bpmnElement="_4" ></span>
<span class="jive-xml-tag"><dc:Bounds x="672" y="216" width="48" height="48" /></span>
<span class="jive-xml-tag"></bpmndi:BPMNShape></span>
<span class="jive-xml-tag"><bpmndi:BPMNEdge bpmnElement="_1-_2" ></span>
<span class="jive-xml-tag"><di:waypoint x="156" y="240" /></span>
<span class="jive-xml-tag"><di:waypoint x="312" y="240" /></span>
<span class="jive-xml-tag"></bpmndi:BPMNEdge></span>
<span class="jive-xml-tag"><bpmndi:BPMNEdge bpmnElement="_2-_3" ></span>
<span class="jive-xml-tag"><di:waypoint x="312" y="240" /></span>
<span class="jive-xml-tag"><di:waypoint x="528" y="240" /></span>
<span class="jive-xml-tag"></bpmndi:BPMNEdge></span>
<span class="jive-xml-tag"><bpmndi:BPMNEdge bpmnElement="_3-_4" ></span>
<span class="jive-xml-tag"><di:waypoint x="528" y="240" /></span>
<span class="jive-xml-tag"><di:waypoint x="696" y="240" /></span>
<span class="jive-xml-tag"></bpmndi:BPMNEdge></span>
<span class="jive-xml-tag"></bpmndi:BPMNPlane></span>
<span class="jive-xml-tag"></bpmndi:BPMNDiagram></span>
<span class="jive-xml-tag"></definitions></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Then I complete the task as following : </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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<String, Object> map) <font color="navy"><b>throws</b></font> Exception
<font color="navy">{</font>
  String name = <font color="red">"client 1"</font>+UUID.randomUUID();
  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())));
  BlockingTaskOperationResponseHandler responseHandler = <font color="navy"><b>new</b></font> BlockingTaskOperationResponseHandler();
  ContentData contentData = <font color="navy"><b>null</b></font>;
  client.connect(ipAddress, port);
  <font color="navy"><b>try</b></font>
  <font color="navy">{</font>
   contentData = ContentMarshallerHelper.marshal(map, <font color="navy"><b>null</b></font>);
   client.complete(taskId, userId, contentData, responseHandler);
   responseHandler.waitTillDone(5000);
   BpmAPI.completeWorkItem(taskId);
  <font color="navy">}</font>
  <font color="navy"><b>catch</b></font>(Exception e)
  <font color="navy">{</font>
   BpmExceptionHandler.handleException(e);
  <font color="navy">}</font>
  <font color="navy"><b>finally</b></font>
  <font color="navy">{</font>
   <font color="navy"><b>if</b></font>(client != <font color="navy"><b>null</b></font>)
   <font color="navy">{</font>
    client.disconnect();
   <font color="navy">}</font>
  <font color="navy">}</font>
<font color="navy">}</font>
 
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </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>