1 2 Previous Next 18 Replies Latest reply on Sep 6, 2011 9:44 AM by calca

    jbpm5 RULEFLOW VARIABLE CHANGED null

    luis.tamayo

      I am getting null pointer exception when I get a process instance variable in drl file.

       

       

      12:48:23,803 INFO  [STDOUT] BEFORE RULEFLOW VARIABLE CHANGED personaVar=null pro

      cess:Requerimiento Permiso[id=org.drools.bpmn2.RequerimientoPermiso]

      12:48:23,803 INFO  [STDOUT] AFTER RULEFLOW VARIABLE CHANGED personaVar=null proc

      ess:Requerimiento Permiso[id=org.drools.bpmn2.RequerimientoPermiso]

      12:48:23,805 INFO  [STDOUT] BEFORE RULEFLOW VARIABLE CHANGED correo=null process

      :Requerimiento Permiso[id=org.drools.bpmn2.RequerimientoPermiso]

       

       

      12:48:23,820 INFO  [STDOUT] AFTER PROCESS NODE TRIGGERED node:Solicitud Empleado

      [id=2] process:Requerimiento Permiso[id=org.drools.bpmn2.RequerimientoPermiso]

      12:48:23,822 INFO  [STDOUT] BEFORE ACTIVATION FIRED rule:Get Information To Star

      t Procedure activationId:Get Information To Start Procedure [1] declarations: $p

      rocessInstance=WorkflowProcessInstance1 [processId=org.drools.bpmn2.Requerimient

      oPermiso,state=1](1) ruleflow-group: envio correo

      12:48:23,822 INFO  [STDOUT] Notification of completed task 1

      12:48:23,824 INFO  [STDOUT] Notification of completed task 1

       

      12:48:23,829 ERROR [STDERR] Exception in thread "Thread-20"

       

      my drl file does very simple test:

       

      import java.util.HashMap;

      import com.lincoln.jbpm.model.Persona;

      import java.io.*;

       

      rule "Get Information To Start Procedure"

          salience 20

          ruleflow-group "envio correo"

          when

              //$correo: Correo()

              $processInstance: WorkflowProcessInstance()

          then

             

              Persona persona = (Persona)$processInstance.getVariable("personaVar");

              persona.setId( "171307" );

              persona.setName( "Test" );

             $processInstance.setVariable("persona",persona);

      end

       

      jbpm51.png

       

      jbpm52.png

      jbpm53.png

       

      At the begn of the process I have set:

      Persona persona = new Persona( "1711xxxx","Luis Tamayo" );

                                    Correo correo = new Correo();

       

                                    params.put("personaVar", persona);

                                    params.put("correo", correo);

       

                                    WorkflowProcessInstance process= (WorkflowProcessInstance)ksession.startProcess("org.drools.bpmn2.RequerimientoPermiso", params);

       

      Whe in do Persona persona = (Persona)$processInstance.getVariable("personaVar"); persona is null.

      I would like to know what I am missing??

       

      Thanks in advance for your help.

        • 1. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
          eaa

          In "Solicitud Empleado", are you giving any value to "persona"? You have configured the output of that Human Task to return a "persona" and to set the value of "personaVal" with its value. So, if you are not providing any "persona" when you are completing the task, "null" is going to be assigned to that variable.

          • 2. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
            luis.tamayo

            Thanks, for your answer.

             

            I run this code to start task:

            public String iniciarTareaSolicitudEmpleado( ){

                                HumanTaskClientMina htk = new HumanTaskClientMina();

                                User u= new User("operator");

                                List<TaskSummary> t = htk.getAssignedTasks( u );

                                System.out.println( "Tarea " + t.get( 0 ).getId() );

                                htk.startTask( u , t.get( 0 ));

                                return null;

                      }

             

            public void startTask(User user, TaskSummary task) {

                                BlockingTaskOperationResponseHandler operationResponseHandler = new BlockingTaskOperationResponseHandler();

                                client.start( task.getId(), user.getId(), operationResponseHandler);

                                operationResponseHandler.waitTillDone(DEFAULT_WAIT_TIME);

                      }

             

            I run this code to complete task:

            public String termiTareaSolicitudEmpleado( ){

                                HumanTaskClientMina htk = new HumanTaskClientMina();

                                User u= new User("operator");

                                List<TaskSummary> t = htk.getAssignedTasks( u );

                                htk.completeTask(u, t.get( 0 ), null);

                                return null;

                      }

             

            public String termiTareaOperator( ){

                                HumanTaskClientMina htk = new HumanTaskClientMina();

                                User u= new User("operator");

                                List<TaskSummary> t = htk.getAssignedTasks( u );

                                Map<String, Object> m = new HashMap<String, Object>();

                                m.put( "persona" , new Persona( "1713", "OSO T" ));

             

                                htk.completeTask(u, t.get( 0 ), null);

                                return null;

                      }

             

            public void completeTask(User user, TaskSummary task, Map data) {

                                BlockingTaskOperationResponseHandler operationResponseHandler = new BlockingTaskOperationResponseHandler();

                                ContentData contentData = null;

                                if (data != null) {

                                          ByteArrayOutputStream bos = new ByteArrayOutputStream();

                                          ObjectOutputStream out;

                                          try {

                                                    out = new ObjectOutputStream(bos);

                                                    out.writeObject(data);

                                                    out.close();

                                                    contentData = new ContentData();

                                                    contentData.setContent(bos.toByteArray());

                                                    contentData.setAccessType(AccessType.Inline);

                                          }

                                          catch (IOException e) {

                                                    System.err.print(e);

                                          }

                                }

                                client.complete(task.getId(), user.getId(), contentData, operationResponseHandler);

                                operationResponseHandler.waitTillDone(DEFAULT_WAIT_TIME);

                      }

             

            Where should i set persona values??

             

            Thanks in advance.

            • 3. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
              eaa

              If you are not planning to modify "persona" in the User Task, then is should be enough to remove it from the Result Mapping attribute of "Solicitud Empleado".

              But, if the User Tasks modifies "persona" in any way, you need to pass it in the Map recevied by:

               

              public void completeTask(User user, TaskSummary task, Map data)

               

              I think, that in your case, you need to pass variable 'm' to the completeTask() method. As far as I can see, you are declaring the Map, setting "persona" in it, but then you are not passing it (as the third parameter) to the completeTask() method.


              • 4. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                salaboy21

                I don't trust in the editor. This problems are usually related with a typo or with some forgotten mapping. If you cannot solve it please share the bpmn/xml file that describe the process, so we can check the mappings.

                Cheers

                • 5. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                  luis.tamayo

                  Thanks, here is the file:

                   

                  <?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="_personaVarItem" structureRef="com.lincoln.jbpm.model.Persona" />

                    <itemDefinition id="_correoItem" structureRef="com.lincoln.jbpm.model.Correo" />

                   

                   

                    <process processType="Private" isExecutable="true" id="org.drools.bpmn2.RequerimientoPermiso" name="Requerimiento Permiso" >

                   

                   

                      <extensionElements>

                       <tns:import name="java.io.*" />

                      </extensionElements>

                      <!-- process variables -->

                      <property id="personaVar" itemSubjectRef="_personaVarItem"/>

                      <property id="correo" itemSubjectRef="_correoItem"/>

                   

                   

                      <!-- nodes -->

                      <startEvent id="_1" name="Start" />

                      <userTask id="_2" name="Solicitud Empleado" >

                        <ioSpecification>

                          <dataInput id="_2_correoInput" name="correo" />

                          <dataInput id="_2_personaInput" name="persona" />

                          <dataInput id="_2_ContentInput" name="Content" />

                          <dataInput id="_2_TaskNameInput" name="TaskName" />

                          <dataOutput id="_2_personaOutput" name="persona" />

                          <dataOutput id="_2_correoOutput" name="correo" />

                          <inputSet>

                            <dataInputRefs>_2_correoInput</dataInputRefs>

                            <dataInputRefs>_2_personaInput</dataInputRefs>

                            <dataInputRefs>_2_ContentInput</dataInputRefs>

                            <dataInputRefs>_2_TaskNameInput</dataInputRefs>

                          </inputSet>

                          <outputSet>

                            <dataOutputRefs>_2_personaOutput</dataOutputRefs>

                            <dataOutputRefs>_2_correoOutput</dataOutputRefs>

                          </outputSet>

                        </ioSpecification>

                        <dataInputAssociation>

                          <sourceRef>correo</sourceRef>

                          <targetRef>_2_correoInput</targetRef>

                        </dataInputAssociation>

                        <dataInputAssociation>

                          <sourceRef>personaVar</sourceRef>

                          <targetRef>_2_personaInput</targetRef>

                        </dataInputAssociation>

                        <dataInputAssociation>

                          <targetRef>_2_ContentInput</targetRef>

                          <assignment>

                            <from xsi:type="tFormalExpression"></from>

                            <to xsi:type="tFormalExpression">_2_ContentInput</to>

                          </assignment>

                        </dataInputAssociation>

                        <dataInputAssociation>

                          <targetRef>_2_TaskNameInput</targetRef>

                          <assignment>

                            <from xsi:type="tFormalExpression">Solicitud de empleado #{personaVar.id}  #{personaVar.name} </from>

                            <to xsi:type="tFormalExpression">_2_TaskNameInput</to>

                          </assignment>

                        </dataInputAssociation>

                        <dataOutputAssociation>

                          <sourceRef>_2_personaOutput</sourceRef>

                          <targetRef>personaVar</targetRef>

                        </dataOutputAssociation>

                        <dataOutputAssociation>

                          <sourceRef>_2_correoOutput</sourceRef>

                          <targetRef>correo</targetRef>

                        </dataOutputAssociation>

                        <potentialOwner>

                          <resourceAssignmentExpression>

                            <formalExpression>operator</formalExpression>

                          </resourceAssignmentExpression>

                        </potentialOwner>

                      </userTask>

                      <businessRuleTask id="_3" name="Correo Requerimiento" g:ruleFlowGroup="envio correo" >

                      </businessRuleTask>

                      <userTask id="_4" name="Aprobacion Requerimiento" >

                        <ioSpecification>

                          <dataInput id="_4_personaInput" name="persona" />

                          <dataInput id="_4_correoInput" name="correo" />

                          <dataInput id="_4_ContentInput" name="Content" />

                          <dataInput id="_4_TaskNameInput" name="TaskName" />

                          <dataOutput id="_4_personaOutput" name="persona" />

                          <dataOutput id="_4_correoOutput" name="correo" />

                          <inputSet>

                            <dataInputRefs>_4_personaInput</dataInputRefs>

                            <dataInputRefs>_4_correoInput</dataInputRefs>

                            <dataInputRefs>_4_ContentInput</dataInputRefs>

                            <dataInputRefs>_4_TaskNameInput</dataInputRefs>

                          </inputSet>

                          <outputSet>

                            <dataOutputRefs>_4_personaOutput</dataOutputRefs>

                            <dataOutputRefs>_4_correoOutput</dataOutputRefs>

                          </outputSet>

                        </ioSpecification>

                        <dataInputAssociation>

                          <sourceRef>personaVar</sourceRef>

                          <targetRef>_4_personaInput</targetRef>

                        </dataInputAssociation>

                        <dataInputAssociation>

                          <sourceRef>correo</sourceRef>

                          <targetRef>_4_correoInput</targetRef>

                        </dataInputAssociation>

                        <dataInputAssociation>

                          <targetRef>_4_ContentInput</targetRef>

                          <assignment>

                            <from xsi:type="tFormalExpression"></from>

                            <to xsi:type="tFormalExpression">_4_ContentInput</to>

                          </assignment>

                        </dataInputAssociation>

                        <dataInputAssociation>

                          <targetRef>_4_TaskNameInput</targetRef>

                          <assignment>

                            <from xsi:type="tFormalExpression">Aprobacion requerimiento #{personaVar.id}  #{personaVar.name} </from>

                            <to xsi:type="tFormalExpression">_4_TaskNameInput</to>

                          </assignment>

                        </dataInputAssociation>

                        <dataOutputAssociation>

                          <sourceRef>_4_personaOutput</sourceRef>

                          <targetRef>personaVar</targetRef>

                        </dataOutputAssociation>

                        <dataOutputAssociation>

                          <sourceRef>_4_correoOutput</sourceRef>

                          <targetRef>correo</targetRef>

                        </dataOutputAssociation>

                        <potentialOwner>

                          <resourceAssignmentExpression>

                            <formalExpression>doctor</formalExpression>

                          </resourceAssignmentExpression>

                        </potentialOwner>

                      </userTask>

                      <endEvent id="_6" name="End" >

                          <terminateEventDefinition/>

                      </endEvent>

                      <task id="_7" name="envio email" tns:taskName="Email" >

                        <extensionElements>

                          <tns:onEntry-script scriptFormat="http://www.java.com/java">

                            <script>try{

                   

                   

                  FileWriter fstream = new FileWriter("c:/emailinscripttask.txt");

                   

                   

                    com.lincoln.jbpm.model.Persona pers = (com.lincoln.jbpm.model.Persona)kcontext.getVariable("personaVar");

                      BufferedWriter out = new BufferedWriter(fstream);

                    if(pers == null  ){

                     out.write("la huevaa es null"  );

                     } else {

                    out.write("caho Java bpm " + pers.getName() );

                    }

                    //Close the output stream

                    out.close();

                    } catch (Exception e){

                              e.printStackTrace();

                    }</script>

                          </tns:onEntry-script>

                          <tns:onExit-script scriptFormat="http://www.java.com/java">

                            <script>try{

                   

                   

                  FileWriter fstream = new FileWriter("c:/emailoutscripttask.txt");

                   

                   

                    com.lincoln.jbpm.model.Persona pers = (com.lincoln.jbpm.model.Persona)kcontext.getVariable("personaVar");

                      BufferedWriter out = new BufferedWriter(fstream);

                    if(pers == null  ){

                     out.write("la huevaa es null"  );

                     } else {

                    out.write("caho Java bpm " + pers.getName() );

                    }

                    //Close the output stream

                    out.close();

                    } catch (Exception e){

                              e.printStackTrace();

                    }</script>

                          </tns:onExit-script>

                        </extensionElements>

                        <ioSpecification>

                          <dataInput id="_7_personaInput" name="persona" />

                          <dataInput id="_7_FromInput" name="From" />

                          <dataOutput id="_7_personaOutput" name="persona" />

                          <inputSet>

                            <dataInputRefs>_7_personaInput</dataInputRefs>

                            <dataInputRefs>_7_FromInput</dataInputRefs>

                          </inputSet>

                          <outputSet>

                            <dataOutputRefs>_7_personaOutput</dataOutputRefs>

                          </outputSet>

                        </ioSpecification>

                        <dataInputAssociation>

                          <sourceRef>personaVar</sourceRef>

                          <targetRef>_7_personaInput</targetRef>

                        </dataInputAssociation>

                        <dataInputAssociation>

                          <targetRef>_7_FromInput</targetRef>

                          <assignment>

                            <from xsi:type="tFormalExpression">luis.tamayo@lincoln-grp.com</from>

                            <to xsi:type="tFormalExpression">_7_FromInput</to>

                          </assignment>

                        </dataInputAssociation>

                        <dataOutputAssociation>

                          <sourceRef>_7_personaOutput</sourceRef>

                          <targetRef>personaVar</targetRef>

                        </dataOutputAssociation>

                      </task>

                   

                   

                      <!-- 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" />

                      <sequenceFlow id="_7-_6" sourceRef="_7" targetRef="_6" />

                      <sequenceFlow id="_4-_7" sourceRef="_4" targetRef="_7" />

                   

                   

                    </process>

                   

                   

                    <bpmndi:BPMNDiagram>

                      <bpmndi:BPMNPlane bpmnElement="org.drools.bpmn2.RequerimientoPermiso" >

                        <bpmndi:BPMNShape bpmnElement="_1" >

                          <dc:Bounds x="100" y="100" width="48" height="48" />

                        </bpmndi:BPMNShape>

                        <bpmndi:BPMNShape bpmnElement="_2" >

                          <dc:Bounds x="237" y="103" width="155" height="48" />

                        </bpmndi:BPMNShape>

                        <bpmndi:BPMNShape bpmnElement="_3" >

                          <dc:Bounds x="435" y="107" width="155" height="48" />

                        </bpmndi:BPMNShape>

                        <bpmndi:BPMNShape bpmnElement="_4" >

                          <dc:Bounds x="671" y="106" width="162" height="48" />

                        </bpmndi:BPMNShape>

                        <bpmndi:BPMNShape bpmnElement="_6" >

                          <dc:Bounds x="1066" y="112" width="48" height="48" />

                        </bpmndi:BPMNShape>

                        <bpmndi:BPMNShape bpmnElement="_7" >

                          <dc:Bounds x="900" y="111" width="100" height="48" />

                        </bpmndi:BPMNShape>

                        <bpmndi:BPMNEdge bpmnElement="_1-_2" >

                          <di:waypoint x="124" y="124" />

                          <di:waypoint x="314" y="127" />

                        </bpmndi:BPMNEdge>

                        <bpmndi:BPMNEdge bpmnElement="_2-_3" >

                          <di:waypoint x="314" y="127" />

                          <di:waypoint x="512" y="131" />

                        </bpmndi:BPMNEdge>

                        <bpmndi:BPMNEdge bpmnElement="_3-_4" >

                          <di:waypoint x="512" y="131" />

                          <di:waypoint x="752" y="130" />

                        </bpmndi:BPMNEdge>

                        <bpmndi:BPMNEdge bpmnElement="_7-_6" >

                          <di:waypoint x="950" y="135" />

                          <di:waypoint x="1090" y="136" />

                        </bpmndi:BPMNEdge>

                        <bpmndi:BPMNEdge bpmnElement="_4-_7" >

                          <di:waypoint x="752" y="130" />

                          <di:waypoint x="950" y="135" />

                        </bpmndi:BPMNEdge>

                      </bpmndi:BPMNPlane>

                    </bpmndi:BPMNDiagram>

                   

                   

                  </definitions>

                  • 6. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                    luis.tamayo

                    I have set the map to content and get this error:

                     

                    Map<String, Object> m = new HashMap<String, Object>();

                                        m.put( "personaVar" , new Persona( "1713", "cnaging" ));

                                        htk.completeTask(u, t.get( 0 ), m);

                     

                     

                    16:15:36,927 ERROR [STDERR] java.lang.ClassNotFoundException: com.lincoln.jbpm.m

                    odel.Persona

                    16:15:36,927 ERROR [STDERR]     at java.net.URLClassLoader$1.run(URLClassLoader.

                    java:202)

                    16:15:36,928 ERROR [STDERR]     at java.security.AccessController.doPrivileged(N

                    • 7. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                      eaa

                      Do you have com.lincoln.jbpm.model.Persona in the application classpath?

                      Are you using jbpm-gwt-console? Where are you getting this error? client application, jbpm runtime or human task server?

                      • 8. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                        luis.tamayo

                        Hi,

                         

                        Persona is in the classpath, it is deployed a as WAR next to bpmn and drl files.

                         

                        I am using Human Task Server, and running the flow through web interface.

                        • 9. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                          luis.tamayo

                          I have fixed this problem, I have to generate a Jar file whith Persona class.

                           

                          I have another issue now, I have this flow:

                           

                          start->Human Task1 -> Rule Task -> Huma Task2 -> Email Task -> Human Task3-> end

                           

                          When i complete human Task 2 trigger Email Task, but Service Task do not get finished, that is the reason why Human Task3 never start.

                           

                          If I use another flow like:

                          start->Human Task1 -> Rule Task1 -> Huma Task2 -> Rule Task2 -> Human Task3-> end

                           

                          It works fine, I would like to know why Email Task does not get ended.

                           

                          Thanks in advance

                          • 10. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                            salaboy21

                            are you registering any workItemHandler for the Email Task?

                            Cheers

                            • 11. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                              luis.tamayo

                              Yes I am

                               

                              ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler( ksession ));

                                                  ksession.getWorkItemManager().registerWorkItemHandler("MiNotificacion", new EmailWorkItemHandler());

                               

                              EmailWorkItemHandler code is:

                               

                              import org.drools.runtime.process.WorkItem;

                              import org.drools.runtime.process.WorkItemHandler;

                              import org.drools.runtime.process.WorkItemManager;

                               

                               

                              public class EmailWorkItemHandler implements WorkItemHandler {

                               

                                        public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

                                                  // extract parameters

                                                  try {

                                                            System.out.println("================================>> ingresa a executeWorkItem EmailWorkItemHandler");

                                                            String from = (String) workItem.getParameter("From");

                                                            System.out.println("================================>> From " + from );

                                                            String to = (String) workItem.getParameter("To");

                                                            //String message = (String) workItem.getParameter("Message");

                               

                               

                               

                                                            manager.completeWorkItem(workItem.getId(),null);

                               

                                                  } catch (Exception e) {

                               

                                                            e.printStackTrace();

                                                  }

                                        }

                               

                                  

                              }

                              • 12. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                                salaboy21

                                are you binding the "

                                 

                                MiNotificacion

                                 

                                To the tns:name attribute in your <task> ??

                                Are you getting those system.outs in your console or an stack trace?

                                The work item should be completed and the process should continue with the information that you are sharing with us.

                                Cheers

                                1 of 1 people found this helpful
                                • 13. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                                  luis.tamayo

                                  Yes, I am mapping, none of the system.out is showing in console.

                                   

                                  flow4.gif

                                  • 14. Re: jbpm5 RULEFLOW VARIABLE CHANGED null
                                    calca

                                    Luis,

                                     

                                    The workitems handlers are mapped to "task types" and not task names. If you are using the custom Email node which comes with the pallete, you should register it with "Email". Otherwise, you will have to register with "tns:taskName" value which you can find it if you open the bpmn as xml.

                                     

                                    Usually, these are custom nodes and you define the "type" in the .conf with your nodes, and there you will find the name of the node type (http://docs.jboss.org/jbpm/v5.1/userguide/ch13.html#d0e3540)

                                     

                                    Demian

                                    1 of 1 people found this helpful
                                    1 2 Previous Next