9 Replies Latest reply on Sep 15, 2011 12:02 AM by Tobias Wittur

    registerWorkItemHandler workItemName

    Tobias Wittur Newbie

      Hello,

       

      I was wondering if the workItemName in - registerWorkItemHandler(String workItemName, WorkItemHandler handler) in public interface WorkItemManager can receive any workItemName.

       

      E.g. I created a standard service task and tried to register my own handler:

       

      ksession.getWorkItemManager().registerWorkItemHandler("Test", new MyOwnServiceHandler());

       

      and I get:

      Caused by: org.drools.WorkItemHandlerNotFoundException: Could not find work item handler for Service Task

       

      If I write this, it works: ksession.getWorkItemManager().registerWorkItemHandler("Service Task", new MyOwnServiceHandler());

       

      Where exactly is the Service Node linked to Service Task? Shouldn't there be something in the XML?

       

        <itemDefinition id="_2_InMessageType" structureRef="java.lang.String" />
        <message id="_2_InMessage" itemRef="_2_InMessageType" />
      
        <interface id="_2_ServiceInterface" name="com.sample.loyaltyManagementHelloService">
          <operation id="_2_ServiceOperation" name="hello">
            <inMessageRef>_2_InMessage</inMessageRef>
          </operation>
        </interface>
      
          <serviceTask id="_3" name="Hello" operationRef="_2_ServiceOperation" implementation="Other" >
            <ioSpecification>
              <dataInput id="_2_param" name="Parameter" />
              <dataOutput id="_2_result" name="Result" />
              <inputSet>
                <dataInputRefs>_2_param</dataInputRefs>
              </inputSet>
              <outputSet>
                <dataOutputRefs>_2_result</dataOutputRefs>
              </outputSet>
            </ioSpecification>
            <dataInputAssociation>
              <sourceRef>x</sourceRef>
              <targetRef>_2_param</targetRef>
            </dataInputAssociation>
            <dataOutputAssociation>
              <sourceRef>_2_result</sourceRef>
              <targetRef>x</targetRef>
            </dataOutputAssociation>
          </serviceTask>   
      

       

      Best regards,

      Tobias

        • 1. Re: registerWorkItemHandler workItemName
          Esteban Aliverti Master

          Are you creating your process using some kind of IDE? 

           

          Try using a <Task> node instead of a <ServiceTask>. Something like:

           

           

          <task id="_11" name="Multiply" tns:taskName="myTaskName">...

           

           

          Then, in your code you can do:

           

          ksession.getWorkItemManager().registerWorkItemHandler("myTaskName", new MyTaskNameWorkItemHandler());

           

          You can also try to use 'tns:taskName' attribute in your <ServiceTask> node to see if it works there too. Please let me know the results.

          • 2. Re: registerWorkItemHandler workItemName
            Tobias Wittur Newbie

            Thank you Esteban,

             

            I will try this next. However, shouldn't ServiceTask be ok according to the BPMN 2.0 Spec?

            Capture2.PNG

             

            I basically just copied the example BPMN2-ServiceProcess and modified it a bit by hand.

            I am still trying to find out,which editor is the best for me... I am having troubles with Oryx as well as the BPMN 20 Eclipse editor plugin.

            I recreated the Example BPMN2-ServiceProcess with the BPMN 20 Eclipse editor plugin, the output looks nice, however the engine does not run it...

             

             

            <?xml version="1.0" encoding="UTF-8"?>
            <bpmn2:definitions 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" 
            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" 
            id="_p7838MxYEeCHXbKuc5-Guw">
            
            
              <bpmn2:process id="_serviceProcess" name="Service Process"  processType="Private" isExecutable="true">
                <bpmn2:startEvent id="_rlr14MxYEeCHXbKuc5-Guw" name="Start">
                  <bpmn2:outgoing>_xORPAMxYEeCHXbKuc5-Guw</bpmn2:outgoing>
                </bpmn2:startEvent>
                <bpmn2:serviceTask id="_2" name="Service Task" implementation="Other" operationRef="_2_ServiceOperation">
                  <bpmn2:incoming>_xORPAMxYEeCHXbKuc5-Guw</bpmn2:incoming>
                  <bpmn2:outgoing>_yqzeccxYEeCHXbKuc5-Guw</bpmn2:outgoing>
                  <bpmn2:ioSpecification id="ioSpecification">
                    <bpmn2:dataInput id="_2_param" name="Parameter"/>
                    <bpmn2:dataOutput id="_2_result" name="Result"/>
                    <bpmn2:inputSet id="_2_param" name="_2_param"/>
                    <bpmn2:outputSet id="_2_result" name="_2_result"/>
                  </bpmn2:ioSpecification>
                  <bpmn2:dataInputAssociation id="_6Sl5wMxZEeCHXbKuc5-Guw">
                    <bpmn2:sourceRef>s</bpmn2:sourceRef>
                    <bpmn2:targetRef>_2_param</bpmn2:targetRef>
                  </bpmn2:dataInputAssociation>
                  <bpmn2:dataOutputAssociation id="_Fe0hoMxaEeCHXbKuc5-Guw">
                    <bpmn2:sourceRef>_2_result</bpmn2:sourceRef>
                    <bpmn2:targetRef>s</bpmn2:targetRef>
                  </bpmn2:dataOutputAssociation>
                </bpmn2:serviceTask>
                <bpmn2:sequenceFlow id="_xORPAMxYEeCHXbKuc5-Guw" name="Sequence Flow" sourceRef="_rlr14MxYEeCHXbKuc5-Guw" targetRef="_2"/>
                <bpmn2:sequenceFlow id="_yqzeccxYEeCHXbKuc5-Guw" name="Sequence Flow" sourceRef="_2" targetRef="_x1Jo0MxYEeCHXbKuc5-Guw"/>
                <bpmn2:endEvent id="_x1Jo0MxYEeCHXbKuc5-Guw" name="End">
                  <bpmn2:incoming>_yqzeccxYEeCHXbKuc5-Guw</bpmn2:incoming>
                </bpmn2:endEvent>
                <bpmn2:property id="s" name="s"/>
              </bpmn2:process>
              <bpmn2:message id="_2_InMessage" itemRef="_2_InMessageType" name="_2_InMessage"/>
              <bpmn2:itemDefinition id="_sItem"/>
              <bpmn2:itemDefinition id="_2_InMessageType"/>
              <bpmn2:interface id="_2_ServiceInterface" name="org.jbpm.examples.junit.HelloService">
                <bpmn2:operation id="_2_ServiceOperation" name="hello"/>
              </bpmn2:interface>
              
              <bpmndi:BPMNDiagram id="_T9_WYMxZEeCHXbKuc5-Guw">
                <bpmndi:BPMNPlane id="_T9_WYcxZEeCHXbKuc5-Guw" bpmnElement="_serviceProcess">
                  <bpmndi:BPMNShape id="_rltrEMxYEeCHXbKuc5-Guw" bpmnElement="_rlr14MxYEeCHXbKuc5-Guw">
                    <dc:Bounds height="51.0" width="36.0" x="166.0" y="179.0"/>
                  </bpmndi:BPMNShape>
                  <bpmndi:BPMNShape id="_wSh_gMxYEeCHXbKuc5-Guw" bpmnElement="_2">
                    <dc:Bounds height="50.0" width="110.0" x="290.0" y="172.0"/>
                  </bpmndi:BPMNShape>
                  <bpmndi:BPMNShape id="_x1K28MxYEeCHXbKuc5-Guw" bpmnElement="_x1Jo0MxYEeCHXbKuc5-Guw">
                    <dc:Bounds height="51.0" width="36.0" x="540.0" y="179.0"/>
                  </bpmndi:BPMNShape>
                  <bpmndi:BPMNShape id="_0TghoMxYEeCHXbKuc5-Guw" bpmnElement="_2_InMessage">
                    <dc:Bounds height="35.0" width="30.0" x="328.0" y="329.0"/>
                  </bpmndi:BPMNShape>
                  <bpmndi:BPMNEdge id="_xOdcQMxYEeCHXbKuc5-Guw" bpmnElement="_xORPAMxYEeCHXbKuc5-Guw" sourceElement="_rltrEMxYEeCHXbKuc5-Guw" targetElement="_wSh_gMxYEeCHXbKuc5-Guw">
                    <di:waypoint xsi:type="dc:Point" x="202.0" y="197.0"/>
                    <di:waypoint xsi:type="dc:Point" x="290.0" y="197.0"/>
                  </bpmndi:BPMNEdge>
                  <bpmndi:BPMNEdge id="_yq0FgMxYEeCHXbKuc5-Guw" bpmnElement="_yqzeccxYEeCHXbKuc5-Guw" sourceElement="_wSh_gMxYEeCHXbKuc5-Guw" targetElement="_x1K28MxYEeCHXbKuc5-Guw">
                    <di:waypoint xsi:type="dc:Point" x="400.0" y="197.0"/>
                    <di:waypoint xsi:type="dc:Point" x="540.0" y="197.0"/>
                  </bpmndi:BPMNEdge>
                </bpmndi:BPMNPlane>
              </bpmndi:BPMNDiagram>
            </bpmn2:definitions>
            

             

             

            The error is :

             

            (null: 8, 30): cvc-elt.1: Cannot find the declaration of element 'bpmn2:definitions'.

            java.lang.IllegalArgumentException: No interfaces found

             

            If I replace it with the definition that is used in all Examples, I get:

             

            The prefix "bpmn2" for element "bpmn2:process" is not bound.


            <definitions id="Definition"
                         targetNamespace="http://www.example.org/MinimalExample"
                         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">
            

            • 3. Re: registerWorkItemHandler workItemName
              Tihomir Surdilovic Master

              Tested your pasted BPMN2 with web Designer (http://www.jboss.org/jbpm/components/designer)  and it worked without issues. I would try with latest release from sourceforge (http://sourceforge.net/projects/jbpm/files/designer/) and please report any issues you run into.

              I have not used the new Eclipse editor much, so can't speak for it. Web Designer is very flexible in that it has independent release cycles from jBPM so we can turn around bug fixes very quickly to end users.

              • 4. Re: registerWorkItemHandler workItemName
                Tihomir Surdilovic Master

                If for any reason you run into problems with latest Designer (1.0.0.054) you can try with latest from master (http://people.redhat.com/tsurdilo/oryx/latest/) but please note this is not an official Designer release.

                • 5. Re: registerWorkItemHandler workItemName
                  Tobias Wittur Newbie

                  Thanks Tihomir,

                   

                  what exactly do you mean by you tested it with the web Designer?

                   

                  I am able to open a web Designer generated process in the eclipse BPMN 2.0 plugin and vice versa. However, when I try to test it with the engine, it does not work. This is my java, that I test the process with:

                   

                   

                  package com.ServiceProcess;
                  
                  public class ProcessTest {
                  
                      public static final void main(String[] args) {
                          try {
                  
                              KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
                              kbuilder.add(ResourceFactory.newClassPathResource("com/ServiceProcess/serviceProcess.bpmn2"), ResourceType.BPMN2);
                              KnowledgeBase kbase = kbuilder.newKnowledgeBase();
                  
                              StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
                  
                              ksession.getWorkItemManager().registerWorkItemHandler("Service Task", new ServiceTaskHandler());
                              Map<String, Object> params = new HashMap<String, Object>();
                              params.put("s", "john");
                              WorkflowProcessInstance processInstance = (WorkflowProcessInstance)
                                  ksession.startProcess("_ServiceProcess", params);
                  
                              if("Hello john!" == processInstance.getVariable("s")){
                                  System.out.println(processInstance.getVariable("s"));    
                              };
                  
                          } catch (Throwable t) {
                              t.printStackTrace();
                          }
                      }
                  
                  }
                  
                  
                  

                   

                  This is the error:

                   

                  (null: 8, 30): cvc-elt.1: Cannot find the declaration of element 'bpmn2:definitions'.
                  java.lang.IllegalArgumentException: No interfaces found
                      at org.jbpm.bpmn2.xml.ServiceTaskHandler.handleNode(ServiceTaskHandler.java:51)
                      at org.jbpm.bpmn2.xml.TaskHandler.end(TaskHandler.java:188)
                      at org.drools.xml.ExtensibleXmlParser.endElement(ExtensibleXmlParser.java:414)
                      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
                      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
                      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
                      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
                      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
                      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
                      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
                      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
                      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
                      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
                      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
                      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
                      at javax.xml.parsers.SAXParser.parse(Unknown Source)
                      at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:293)
                      at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:172)
                      at org.jbpm.compiler.xml.XmlProcessReader.read(XmlProcessReader.java:46)
                      at org.jbpm.compiler.ProcessBuilderImpl.addProcessFromXml(ProcessBuilderImpl.java:249)
                      at org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.java:516)
                      at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:560)
                      at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
                      at com.ServiceProcess.ProcessTest.main(ProcessTest.java:27)
                  org.drools.compiler.ProcessLoadError: unable to parse xml : Exception class java.lang.IllegalArgumentException : No interfaces found
                  java.lang.IllegalArgumentException: Could not parse knowledge.
                      at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:58)
                      at com.ServiceProcess.ProcessTest.main(ProcessTest.java:28)
                  
                  • 6. Re: registerWorkItemHandler workItemName
                    Esteban Aliverti Master

                    It seems that if you want to usa a  then you need to define the interface of your service in the process definition. The interface defines an operation and then you can use that operation in your  node.  Here is an example: https://github.com/droolsjbpm/jbpm/blob/master/jbpm-bpmn2/src/test/resources/BPMN2-ServiceProcess.bpmn2  This is a generic way to invoke services, but I'm not sure if it is the best. If you use a  then you need to register a generic "ServiceTaskHandler" to it. Because it is generic, you can attach the same handler to all your  nodes.  The ServiceTaskHandler class is a WorkItemHandler that will take the parameters defined in the  your  references, instantiate a new class (the one defined in 's 'name' attribute) using reflection, and finally it will try to invoke the method defined by the  element. For simple scenarios, this could be enough, but for more complex situations, I think a plain  node with a custom WorkItemHandler is much better.  Here is the implementation of ServiceTaskHandler: https://github.com/droolsjbpm/jbpm/blob/master/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/handler/ServiceTaskHandler.java  Because  node has this 'generic' behavior, I'm not sure if you can attach different Handlers to different node instances. Again, I think a  node is much better. 

                    • 7. Re: registerWorkItemHandler workItemName
                      Tihomir Surdilovic Master

                      I made sure it opens fine in Designer. I have not played with the new Eclipse BPMN2 editor much but here is the BPMN2 produced by Designer with a very similar process as yours (start task, service node, end task):

                       

                      1.|<?xml version="1.0" encoding="UTF-8"?>
                      2.|<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.omg.org/bpmn20" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" 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:drools="http://www.jboss.org/drools" id="a89e1d83-57d7-441e-bde7-bcfc07046877" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" name="Sample Service Process" targetNamespace="http://www.omg.org/bpmn20">
                      3.|<bpmn2:itemDefinition id="_sItem" structureRef="String"/>
                      4.|<bpmn2:process id="serviceProcess" drools:packageName="defaultPackage" name="Sample Service Process" isExecutable="true">
                      5.|<bpmn2:startEvent id="_AE376570-6FDE-4862-AAB0-8FE9AFB6F3F9" name="">
                      6.|<bpmn2:outgoing>_BF300974-57DC-4219-82F6-5BA95FC29589</bpmn2:outgoing>
                      7.|</bpmn2:startEvent>
                      8.|<bpmn2:serviceTask id="_8D551B36-A5AF-4808-9D50-7691FB2A1B87" drools:servicetaskinterface="org.jbpm.examples.junit.HelloService" drools:servicetaskoperation="hello" name="Service Task" implementation="Other" operationRef="_8D551B36-A5AF-4808-9D50-7691FB2A1B87_ServiceOperation">
                      9.|<bpmn2:incoming>_BF300974-57DC-4219-82F6-5BA95FC29589</bpmn2:incoming>
                      10.|<bpmn2:outgoing>_1F57B200-3F32-45BC-A775-BB3FC333EAF6</bpmn2:outgoing>
                      11.|<bpmn2:ioSpecification id="_5Qp0ocymEeCp6N3BENwuag">
                      12.|<bpmn2:dataInput id="_8D551B36-A5AF-4808-9D50-7691FB2A1B87_ParameterInput" name="Parameter"/>
                      13.|<bpmn2:dataOutput id="_8D551B36-A5AF-4808-9D50-7691FB2A1B87_ResultOutput" name="Result"/>
                      14.|<bpmn2:inputSet id="_5Qp0osymEeCp6N3BENwuag">
                      15.|<bpmn2:dataInputRefs>_8D551B36-A5AF-4808-9D50-7691FB2A1B87_ParameterInput</bpmn2:dataInputRefs>
                      16.|</bpmn2:inputSet>
                      17.|<bpmn2:outputSet id="_5Qp0o8ymEeCp6N3BENwuag">
                      18.|<bpmn2:dataOutputRefs>_8D551B36-A5AF-4808-9D50-7691FB2A1B87_ResultOutput</bpmn2:dataOutputRefs>
                      19.|</bpmn2:outputSet>
                      20.|</bpmn2:ioSpecification>
                      21.|<bpmn2:dataInputAssociation id="_5Qp0pMymEeCp6N3BENwuag">
                      22.|<bpmn2:sourceRef>s</bpmn2:sourceRef>
                      23.|<bpmn2:targetRef>_8D551B36-A5AF-4808-9D50-7691FB2A1B87_ParameterInput</bpmn2:targetRef>
                      24.|</bpmn2:dataInputAssociation>
                      25.|<bpmn2:dataOutputAssociation id="_5QqbsMymEeCp6N3BENwuag">
                      26.|<bpmn2:sourceRef>_8D551B36-A5AF-4808-9D50-7691FB2A1B87_ResultOutput</bpmn2:sourceRef>
                      27.|<bpmn2:targetRef>s</bpmn2:targetRef>
                      28.|</bpmn2:dataOutputAssociation>
                      29.|</bpmn2:serviceTask>
                      30.|<bpmn2:sequenceFlow id="_BF300974-57DC-4219-82F6-5BA95FC29589" sourceRef="_AE376570-6FDE-4862-AAB0-8FE9AFB6F3F9" targetRef="_8D551B36-A5AF-4808-9D50-7691FB2A1B87"/>
                      31.|<bpmn2:sequenceFlow id="_1F57B200-3F32-45BC-A775-BB3FC333EAF6" sourceRef="_8D551B36-A5AF-4808-9D50-7691FB2A1B87" targetRef="_B68024DD-A828-494F-843A-29C48087EEFB"/>
                      32.|<bpmn2:endEvent id="_B68024DD-A828-494F-843A-29C48087EEFB" name="">
                      33.|<bpmn2:incoming>_1F57B200-3F32-45BC-A775-BB3FC333EAF6</bpmn2:incoming>
                      34.|<bpmn2:terminateEventDefinition id="_5QqbscymEeCp6N3BENwuag"/>
                      35.|</bpmn2:endEvent>
                      36.|<bpmn2:property id="s" itemSubjectRef="_sItem"/>
                      37.|</bpmn2:process>
                      38.|<bpmn2:interface id="_8D551B36-A5AF-4808-9D50-7691FB2A1B87_ServiceInterface" name="org.jbpm.examples.junit.HelloService">
                      39.|<bpmn2:operation id="_8D551B36-A5AF-4808-9D50-7691FB2A1B87_ServiceOperation" name="hello">
                      40.|<bpmn2:inMessageRef>_8D551B36-A5AF-4808-9D50-7691FB2A1B87_InMessage</bpmn2:inMessageRef>
                      41.|</bpmn2:operation>
                      42.|</bpmn2:interface>
                      43.|<bpmn2:message id="_8D551B36-A5AF-4808-9D50-7691FB2A1B87_InMessage" itemRef="_8D551B36-A5AF-4808-9D50-7691FB2A1B87_InMessageType"/>
                      44.|<bpmn2:itemDefinition id="_8D551B36-A5AF-4808-9D50-7691FB2A1B87_InMessageType"/>
                      45.|<bpmndi:BPMNDiagram id="_5QqbssymEeCp6N3BENwuag">
                      46.|<bpmndi:BPMNPlane id="_5Qqbs8ymEeCp6N3BENwuag" bpmnElement="serviceProcess">
                      47.|<bpmndi:BPMNShape id="_5QqbtMymEeCp6N3BENwuag" bpmnElement="_AE376570-6FDE-4862-AAB0-8FE9AFB6F3F9">
                      48.|<dc:Bounds height="30.0" width="30.0" x="144.0" y="206.0"/>
                      49.|</bpmndi:BPMNShape>
                      50.|<bpmndi:BPMNShape id="_5QqbtcymEeCp6N3BENwuag" bpmnElement="_8D551B36-A5AF-4808-9D50-7691FB2A1B87">
                      51.|<dc:Bounds height="80.0" width="100.0" x="219.0" y="181.0"/>
                      52.|</bpmndi:BPMNShape>
                      53.|<bpmndi:BPMNEdge id="_5QqbtsymEeCp6N3BENwuag" bpmnElement="_BF300974-57DC-4219-82F6-5BA95FC29589">
                      54.|<di:waypoint xsi:type="dc:Point" x="159.0" y="221.0"/>
                      55.|<di:waypoint xsi:type="dc:Point" x="269.0" y="221.0"/>
                      56.|</bpmndi:BPMNEdge>
                      57.|<bpmndi:BPMNEdge id="_5Qqbt8ymEeCp6N3BENwuag" bpmnElement="_1F57B200-3F32-45BC-A775-BB3FC333EAF6">
                      58.|<di:waypoint xsi:type="dc:Point" x="269.0" y="221.0"/>
                      59.|<di:waypoint xsi:type="dc:Point" x="378.0" y="221.0"/>
                      60.|</bpmndi:BPMNEdge>
                      61.|<bpmndi:BPMNShape id="_5QqbuMymEeCp6N3BENwuag" bpmnElement="_B68024DD-A828-494F-843A-29C48087EEFB">
                      62.|<dc:Bounds height="28.0" width="28.0" x="364.0" y="207.0"/>
                      63.|</bpmndi:BPMNShape>
                      64.|</bpmndi:BPMNPlane>
                      65.|</bpmndi:BPMNDiagram>
                      66.|</bpmn2:definitions>
                      • 8. Re: registerWorkItemHandler workItemName
                        Tobias Wittur Newbie

                        @Esteban

                         

                         

                         

                        Thanks Esteban, I already copied the ServiceTaskHandler class and invoked my own java class with it, similar to the HelloProcess Example. So this works.

                         

                         

                         

                        The interface was a bit hidden, but already defined in the example above:

                         

                         

                          <bpmn2:interface id="_2_ServiceInterface" name="org.jbpm.examples.junit.HelloService">
                            <bpmn2:operation id="_2_ServiceOperation" name="hello"/>
                          </bpmn2:interface>

                         

                         

                         

                        I am successfully invoking a webservice with it and transfering json data in my process. So finally a feeling of success

                         

                         

                        @Tihomir

                         


                         

                        I never really had an issue with opening the xml from the BPMN Eclipse 2.0 Editor in Oryx or vice versa. Oryx and the Eclipse BPMN 2.0 Editor work perfectly together and are in my opinion also compliant with the BPMN 2.0 spec. My problem is solely the execution of an Oryx generated xml code in eclipse with a processTest.java file.

                         

                         

                         

                        I wrote the whole xml again by hand and now it works (The example below is a bit more advance at this stage already). I think I will go on coding it by hand for now.

                         

                        However, it would be nice if the example (working in oryx and eclipse editor plugin) that I posted above would be executable. It is the same semantic structure as the xml below. So it must be a syntax issue.

                         

                         

                        <?xml version="1.0" encoding="UTF-8"?> 
                        <definitions id="Definition"
                                     targetNamespace="http://www.example.org/MinimalExample"
                                     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="xItemDef" />
                            <itemDefinition id="bItemDef" />
                            <itemDefinition id="StartProcessMessageType" structureRef="java.lang.String" />
                            <itemDefinition id="requestBadgeMessageType" structureRef="java.lang.Object" />
                            <itemDefinition id="requestLoyaltyStatusMessageType" structureRef="java.lang.Object" />
                        
                            <message id="StartProcessMessage" itemRef="StartProcessMessageType" />
                            <message id="requestLoyaltyStatusMessage" itemRef="requestLoyaltyStatusMessageType" />
                            <message id="requestBadgeMessage" itemRef="requestBadgeMessageType" />
                        
                          <interface id="requestLoyaltyStatusInterface" name="loyaltyManagement2.requestLoyaltyStatus">
                            <operation id="requestLoyaltyStatusOperation" name="hello">
                              <inMessageRef>requestLoyaltyStatusMessage</inMessageRef>
                            </operation>
                          </interface>
                        
                            <interface id="requestBadgeInterface" name="loyaltyManagement2.requestBadge">
                            <operation id="requestBadgeOperation" name="hello">
                              <inMessageRef>requestBadgeMessage</inMessageRef>
                            </operation>
                          </interface>
                        
                          <process processType="Private" id="ServiceProcess" name="Service Process" isExecutable="true" tns:packageName="com.sample" >
                        
                            <property id="s" itemSubjectRef="xItemDef"/>
                            <property id="b" itemSubjectRef="bItemDef"/>
                        
                            <!-- Start Event-->
                            <startEvent id="messageStartEvent" name="StartProcess" >
                              <dataOutput id="messageStartEventOutput" />
                              <dataOutputAssociation>
                                <sourceRef>messageStartEventOutput</sourceRef>
                                <targetRef>s</targetRef>
                              </dataOutputAssociation>
                              <outputSet>
                                <dataOutputRefs>messageStartEventOutput</dataOutputRefs>
                              </outputSet>
                              <messageEventDefinition messageRef="StartProcessMessage"/>
                            </startEvent>
                        
                            <!-- Script Task-->
                            <scriptTask id="_2" name="Scipt Task - Value Printer" >
                              <script>System.out.println("s = " + s);</script>
                            </scriptTask>
                        
                            <!-- Service Task -->
                            <serviceTask id="_4" name="requestLoyaltyStatus" operationRef="requestLoyaltyStatusOperation" implementation="Other" >
                              <ioSpecification>
                                <dataInput id="requestLoyaltyStatusParam" name="Parameter" />
                                <dataOutput id="requestLoyaltyStatusResult" name="Result" />
                                <inputSet>
                                  <dataInputRefs>requestLoyaltyStatusParam</dataInputRefs>
                                </inputSet>
                                <outputSet>
                                  <dataOutputRefs>requestLoyaltyStatusResult</dataOutputRefs>
                                </outputSet>
                              </ioSpecification>
                              <dataInputAssociation>
                                <sourceRef>s</sourceRef>
                                <targetRef>requestLoyaltyStatusParam</targetRef>
                              </dataInputAssociation>
                              <dataOutputAssociation>
                                <sourceRef>requestLoyaltyStatusResult</sourceRef>
                                <targetRef>s</targetRef>
                              </dataOutputAssociation>
                            </serviceTask>    
                        
                            <!-- Service Task -->
                            <serviceTask id="_5" name="requestBadge" operationRef="requestBadgeOperation" implementation="Other" >
                              <ioSpecification>
                                <dataInput id="requestBadgeParam" name="Parameter" />
                                <dataOutput id="requestBadgeResult" name="Result" />
                                <inputSet>
                                  <dataInputRefs>requestBadgeParam</dataInputRefs>
                                </inputSet>
                                <outputSet>
                                  <dataOutputRefs>requestBadgeResult</dataOutputRefs>
                                </outputSet>
                              </ioSpecification>
                              <dataInputAssociation>
                                <sourceRef>s</sourceRef>
                                <targetRef>requestBadgeParam</targetRef>
                              </dataInputAssociation>
                              <dataOutputAssociation>
                                <sourceRef>requestBadgeResult</sourceRef>
                                <targetRef>b</targetRef>
                              </dataOutputAssociation>
                            </serviceTask>    
                        
                            <!-- Script Task-->
                            <scriptTask id="_6" name="Scipt Task - Value Printer" >
                              <script>System.out.println("b = " + b);</script>
                            </scriptTask>
                        
                            <!-- End Event-->
                            <endEvent id="_3" name="EndProcess" >
                                <terminateEventDefinition/>
                            </endEvent>
                        
                            <!-- Connections-->
                            <sequenceFlow id="messageStartEvent-_2" sourceRef="messageStartEvent" targetRef="_2" />
                            <sequenceFlow id="_2-_4" sourceRef="_2" targetRef="_4" />
                            <sequenceFlow id="_4-_5" sourceRef="_4" targetRef="_5" />    
                            <sequenceFlow id="_5-_6" sourceRef="_5" targetRef="_6" />
                            <sequenceFlow id="_6-_3" sourceRef="_6" targetRef="_3" />    
                        
                          </process>
                        
                        
                        
                        </definitions>
                        

                         

                         

                         


                        • 9. Re: registerWorkItemHandler workItemName
                          Tobias Wittur Newbie

                          Esteban,

                           

                          let's say I have several message throw events in one process. Those are all registered to a generic sendTaskHandler.

                           

                          https://github.com/droolsjbpm/jbpm/blob/master/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/handler/SendTaskHandler.java

                           

                          However, since there is no interface or operation connected, how would I trigger a suitable action for each particular message throw event?

                           

                          As shown in this unit test:

                          KnowledgeBase kbase = createKnowledgeBase("BPMN2-IntermediateThrowEventMessage.bpmn2");

                          StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);

                          ksession.getWorkItemManager().registerWorkItemHandler("Send Task", new SendTaskHandler());

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

                          params.put("x", "MyValue");

                          ProcessInstance processInstance = ksession.startProcess("MessageIntermediateEvent", params);