AnsweredAssumed Answered

How to pass a variable from one java service task to another

Question asked by raaj1 on Jul 19, 2014
Latest reply on Aug 6, 2014 by frederikheremans1
Hi all,

Can Anyone please tell me how do i pass a variable form one service task to another.
Following is my bpmn20.xml file
<process id="process" isExecutable="true">
    <startEvent id="sid-5FC149C0-7879-4862-B61B-4F9E42EEA903"/>
   
    <serviceTask id="sid-C911DB7F-5A82-49EE-92E6-21BD24C37A0F"  name="Number1" activiti:exclusive="false" activiti:class="com.FirstNumberTask" />
   
   
    <sequenceFlow id="sid-9E3EB3DD-07B9-453D-8DA3-CA3A9490CBAE" sourceRef="sid-5FC149C0-7879-4862-B61B-4F9E42EEA903" targetRef="sid-C911DB7F-5A82-49EE-92E6-21BD24C37A0F"/>
    <serviceTask id="sid-7C471866-C110-48D1-8704-3F2DBE9963DB" name="Number2" activiti:exclusive="false" activiti:class="com.SecondNumberTask" />
    <sequenceFlow id="sid-0B941981-9EF1-4C71-BAD5-9A65D43FAFCD" sourceRef="sid-C911DB7F-5A82-49EE-92E6-21BD24C37A0F" targetRef="sid-7C471866-C110-48D1-8704-3F2DBE9963DB"/>
   ……………

I need to pass a number from first task to second task.I tried using the setVariable and getVariable method ,but i am getting a null pointer exception.

For eg:

I set a variable number1 in the first task using execution.setVariable(number1,"2") ,method.When I try to retrieve the number1's value  in my second task I am getting a Null Pointer Exception.I am new to Activiti Framework,Can anybody please help me?Thank you in advance

Outcomes