-
1. Re: ProcessContext Throwing NPE
roxy1987 Mar 11, 2013 12:04 PM (in response to roxy1987)Guys,
Any Help on this please?
Regards.
-
2. Re: ProcessContext Throwing NPE
thomas.setiabudi Mar 12, 2013 10:42 PM (in response to roxy1987)Hi Roxy,
Do you want to set "process variable" or "task output variable"?
Your code seems to try to set "process variable"
How about setting the variable via the Task Output Variable and then map those task output to the process variable that you want to set. That works with JBPM5.4..
Regards,
Thomas Setiabudi
-
3. Re: ProcessContext Throwing NPE
roxy1987 Mar 13, 2013 11:26 AM (in response to thomas.setiabudi)Hi Thomas,
I wanna set a variable after the process has been started. For instance, consider a process with 2 tasks.
User fills in a text field(say 'newUser') while completing 1st task and the value of the text field is used as the actor id for the next task('#newUser').
And I dont wanna use any script node in between.
I have tried using a Map and putting it in the content of the task and mapping with out parameter but no luck. So probably I did nt use it correctly. So may be you could give me a running example code.
Thanks.
-
4. Re: ProcessContext Throwing NPE
thomas.setiabudi Mar 13, 2013 11:44 PM (in response to roxy1987)Hi, (changed your name is it? was Roxy1987 right?)
So please find the attached process definition (test1.testAssignUser.v1.bpmn2)
The process has two process variables, they are:
1. pvFirstActor
2. pvSecondActor
The process is like what you said, it has 2 human task:
1. HumanTask1 with actor Id taken from the value of "pvFirstActor"
2. HumanTask2 with actor Id taken from the value of "pvSecondActor"
when we first start process we set the value of variable "pvFirstActor" that will be used as the first Human Task actor Id
then the first human task has output variable that called "secondActorName" that is mapped to "pvSecondActor"
so after we complete HumanTask1 then the value of "pvSecondActor" will be set based on the output of the HumanTask1
Attached a working test case too, look at the testAssignVariableAsActorId() test function inside PersistentProcessTest class in jbpm5-PersistentProcess.7z (it is based on sample from Mauricio Salatino / Salaboy)
Regards,
Thomas Setiabudi
-
jBPM5-PersistentProcess.7z.zip 33.4 KB
-
-
5. Re: ProcessContext Throwing NPE
roxy1987 Mar 14, 2013 10:59 AM (in response to thomas.setiabudi)Yeah my user id was getting displayed so I changed that.
Well thank you so much Thomas.
-
6. Re: ProcessContext Throwing NPE
roxy1987 Mar 14, 2013 12:49 PM (in response to thomas.setiabudi)Thomas,
I tried the code. but it didnt work. Its the same thing. Following is my process def :
<?xml version="1.0" encoding="UTF-8"?> <definitions id="Definition" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes" expressionLanguage="http://www.mvel.org/2.0" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" xmlns:g="http://www.jboss.org/drools/flow/gpd" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.jboss.org/drools"> <itemDefinition id="_taskUserItem" structureRef="String" /> <itemDefinition id="_2-taskUserItem" structureRef="String" /> <itemDefinition id="_3-taskUserItem" structureRef="String" /> <process processType="Private" isExecutable="true" id="com.sample.dynamicTaskVariable" name="Dynamic Task Variable Process" tns:packageName="defaultPackage" > <!-- process variables --> <property id="taskUser" itemSubjectRef="_taskUserItem"/> <!-- nodes --> <startEvent id="_1" name="StartProcess" /> <userTask id="_2" name="Create Variable" > <ioSpecification> <dataInput id="_2_TaskNameInput" name="TaskName" /> <dataInput id="_2_CommentInput" name="Comment" /> <dataOutput id="_2_taskVariableOutput" name="taskVariable" /> <inputSet> <dataInputRefs>_2_TaskNameInput</dataInputRefs> <dataInputRefs>_2_CommentInput</dataInputRefs> </inputSet> <outputSet> <dataOutputRefs>_2_taskVariableOutput</dataOutputRefs> </outputSet> </ioSpecification> <dataInputAssociation> <targetRef>_2_TaskNameInput</targetRef> <assignment> <from xsi:type="tFormalExpression">Create Variable</from> <to xsi:type="tFormalExpression">_2_TaskNameInput</to> </assignment> </dataInputAssociation> <dataInputAssociation> <targetRef>_2_CommentInput</targetRef> <assignment> <from xsi:type="tFormalExpression">createVariable.xhtml</from> <to xsi:type="tFormalExpression">_2_CommentInput</to> </assignment> </dataInputAssociation> <dataOutputAssociation> <sourceRef>_2_taskVariableOutput</sourceRef> <targetRef>taskUser</targetRef> </dataOutputAssociation> <potentialOwner> <resourceAssignmentExpression> <formalExpression>krisv</formalExpression> </resourceAssignmentExpression> </potentialOwner> </userTask> <userTask id="_3" name="Verify Variable" > <ioSpecification> <dataInput id="_3_TaskNameInput" name="TaskName" /> <dataInput id="_3_CommentInput" name="Comment" /> <inputSet> <dataInputRefs>_3_TaskNameInput</dataInputRefs> <dataInputRefs>_3_CommentInput</dataInputRefs> </inputSet> <outputSet> </outputSet> </ioSpecification> <dataInputAssociation> <targetRef>_3_TaskNameInput</targetRef> <assignment> <from xsi:type="tFormalExpression">Verify Variable</from> <to xsi:type="tFormalExpression">_3_TaskNameInput</to> </assignment> </dataInputAssociation> <dataInputAssociation> <targetRef>_3_CommentInput</targetRef> <assignment> <from xsi:type="tFormalExpression">verifyVariable.xhtml</from> <to xsi:type="tFormalExpression">_3_CommentInput</to> </assignment> </dataInputAssociation> <potentialOwner> <resourceAssignmentExpression> <formalExpression>#{taskUser}</formalExpression> </resourceAssignmentExpression> </potentialOwner> </userTask> <endEvent id="_4" name="End" > <terminateEventDefinition /> </endEvent> <!-- connections --> <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" /> <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" /> <sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" /> </process> <bpmndi:BPMNDiagram> <bpmndi:BPMNPlane bpmnElement="com.sample.dynamicTaskVariable" > <bpmndi:BPMNShape bpmnElement="_1" > <dc:Bounds x="132" y="216" width="48" height="48" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_2" > <dc:Bounds x="228" y="204" width="169" height="73" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_3" > <dc:Bounds x="444" y="204" width="169" height="73" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_4" > <dc:Bounds x="672" y="216" width="48" height="48" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="_1-_2" > <di:waypoint x="156" y="240" /> <di:waypoint x="312" y="240" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="_2-_3" > <di:waypoint x="312" y="240" /> <di:waypoint x="528" y="240" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="_3-_4" > <di:waypoint x="528" y="240" /> <di:waypoint x="696" y="240" /> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </definitions>
Then I complete the task as following :
public static void completeTask(long taskId, String userId, Map<String, Object> map) throws Exception { String name = "client 1"+UUID.randomUUID(); TaskClient client = new TaskClient(new HornetQTaskClientConnector(name, new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()))); BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler(); ContentData contentData = null; client.connect(ipAddress, port); try { contentData = ContentMarshallerHelper.marshal(map, null); client.complete(taskId, userId, contentData, responseHandler); responseHandler.waitTillDone(5000); BpmAPI.completeWorkItem(taskId); } catch(Exception e) { BpmExceptionHandler.handleException(e); } finally { if(client != null) { client.disconnect(); } } }
In the map above I put a variable for next task.
Only difference in the code is that I complete the task and then I complete the work item.
Regards.