4 Replies Latest reply on Jul 18, 2014 4:23 PM by tujasiri

    Striving to invoke a Java Method via a Service Task in JBPM 6

    tujasiri

      I'm striving to invoke a method from a service task. I've followed a few suggestions and examples, mainly Maciej Swiderski's-->HERE. I think everything set up correctly, for the most part, but my custom method is not being called.

      I've:

      • created the class with will execute my "task"
      • created the necessary conf, and wid files
      • registered my WorkItemHandler (and the executeWorkItem method is invoked)

      And here are BPMN file contents:

       

       

      
      

      <?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="_sItem" structureRef="String" />
        
      <itemDefinition id="_jbpm-unique-3_InMessageType" structureRef="java.lang.String" />
        
      <message id="_jbpm-unique-3_InMessage" itemRef="_jbpm-unique-3_InMessageType" />
       
      <interface id="_jbpm-unique-3_ServiceInterface" name="com.sample.BriefVerify"  implementationRef="" >
        
      <operation id="_jbpm-unique-3_ServiceOperation" name="sayHello" implementationRef="" >
        
      <inMessageRef>_jbpm-unique-3_InMessage</inMessageRef>
        
      </operation>
       
      </interface>
       
      <process processType="Private" isExecutable="true" id="com.sample.bpmn.ServiceProcess" name="Service Process" >
        
      <!-- process variables -->
        
      <property id="s" itemSubjectRef="_sItem"/>
        
      <!-- nodes -->
       
      <startEvent id="_jbpm-unique-2" name="Start"  isInterrupting="false"/>
       
      <serviceTask id="_jbpm-unique-3" name="Hello" operationRef="_jbpm-unique-3_ServiceOperation" implementation="Other" >
       
      <ioSpecification>
        
      <dataInput id="_jbpm-unique-3_param" name="Parameter" />
        
      <dataOutput id="_jbpm-unique-3_result" name="Result" />
        
      <inputSet>
        
      <dataInputRefs>_jbpm-unique-3_param</dataInputRefs>
        
      </inputSet>
        
      <outputSet>
        
      <dataOutputRefs>_jbpm-unique-3_result</dataOutputRefs>
        
      </outputSet>
       
      </ioSpecification>
      </serviceTask>
      <endEvent id="_jbpm-unique-4" name="End" >
        
      <terminateEventDefinition />
      </endEvent>
      <!-- connections -->
      <sequenceFlow id="_jbpm-unique-2-_jbpm-unique-3" sourceRef="_jbpm-unique-2" targetRef="_jbpm-unique-3" />
       
      <sequenceFlow id="_jbpm-unique-3-_jbpm-unique-4" sourceRef="_jbpm-unique-3" targetRef="_jbpm-unique-4" />
      </process>
      <bpmndi:BPMNDiagram>
      <bpmndi:BPMNPlane bpmnElement="com.sample.bpmn.ServiceProcess" >
       
      <bpmndi:BPMNShape bpmnElement="_jbpm-unique-2" >
        
      <dc:Bounds x="0" y="0" width="48" height="48" />
       
      </bpmndi:BPMNShape>
       
      <bpmndi:BPMNShape bpmnElement="_jbpm-unique-3" >
        
      <dc:Bounds x="197" y="3" width="100" height="48" />
       
      </bpmndi:BPMNShape>
       
      <bpmndi:BPMNShape bpmnElement="_jbpm-unique-4" >
        
      <dc:Bounds x="0" y="0" width="48" height="48" />
       
      </bpmndi:BPMNShape>
       
      <bpmndi:BPMNEdge bpmnElement="_jbpm-unique-2-_jbpm-unique-3" >
        
      <di:waypoint x="24" y="24" />
        
      <di:waypoint x="247" y="27" />
       
      </bpmndi:BPMNEdge>
       
      <bpmndi:BPMNEdge bpmnElement="_jbpm-unique-3-_jbpm-unique-4" >
        
      <di:waypoint x="247" y="27" />
        
      <di:waypoint x="24" y="24" />
       
      </bpmndi:BPMNEdge>
      </bpmndi:BPMNPlane>
      </bpmndi:BPMNDiagram>
      </definitions>


      The rest of the files are here: https://github.com/tujasiri/BriefReqVerify

      Any help is appreciated!

      -TU

        • 1. Re: Striving to invoke a Java Method via a Service Task in JBPM 6
          salaboy21

          Can you explain what is the issue that you are getting?

          Regards

          • 2. Re: Striving to invoke a Java Method via a Service Task in JBPM 6
            lauradp

            Hi,

            If you are running this workItemHandler https://github.com/tujasiri/BriefReqVerify/blob/master/src/main/java/com/sample/MyWorkItemHandler.java

            I cannot see any custom method invocation.

             

            public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

                    System.out.println("GOOD BYE WORLD");

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

                }

             

            Please can you verify your code on github is correct or provide any trace?

             

            HTH

             

            Laura

            • 3. Re: Striving to invoke a Java Method via a Service Task in JBPM 6
              tujasiri

              Yes, that is the code.  I don't have a stack trace.

               

              I thought the actual invocation happened in the BPMN file.

               

              Here:

               

               

                <interface id="_jbpm-unique-3_ServiceInterface" name="com.sample.BriefVerify" implementationRef="" >

                  <operation id="_jbpm-unique-3_ServiceOperation" name="sayHello" implementationRef="" >

                    <inMessageRef>_jbpm-unique-3_InMessage</inMessageRef>

                  </operation>

                </interface>

               

               

                and then in the <serviceTask> element:

               

                  <serviceTask id="_jbpm-unique-3" name="Hello" operationRef="_jbpm-unique-3_ServiceOperation" implementation="Other" >

                    <ioSpecification>

                      <dataInput id="_jbpm-unique-3_param" name="Parameter" />

                      <dataOutput id="_jbpm-unique-3_result" name="Result" />

                      <inputSet>

                        <dataInputRefs>_jbpm-unique-3_param</dataInputRefs>

                      </inputSet>

                      <outputSet>

                        <dataOutputRefs>_jbpm-unique-3_result</dataOutputRefs>

                      </outputSet>

                    </ioSpecification>

                  </serviceTask>

               

               

              Should I be doing some work in the executeWorkItem() method?

               

              I was able to dump the workitem object the Interface and Operation properties corresponding with the <interface> and <operation> elements are set.  I don't know what's supposed to make the method call.

               

              Screen Shot 2014-07-16 at 6.18.34 PM.png

              • 4. Re: Striving to invoke a Java Method via a Service Task in JBPM 6
                tujasiri

                Thank you very much lauradp.  My task is launching now and I'm proceeding.  I don't now how I missed the actually invocation of the method having to be in "executeWorkItem()"!