5 Replies Latest reply on Aug 15, 2011 8:51 PM by tob1as

    Could not find work item handler

    tob1as

      Hi,

       

      I am trying to send a message through an intermediate message throw event. However, I ve got troubles registering a work item handler for this.

       

      I had a look at the test case in the junit example package testMessageIntermediateThrow().

       

      I copied the Meta-Inf folder in my own project and created my own workItemHandler. I basically just copied the intermediateEvent xml into my bpmn file.

       

      project structure.PNG

       

      The error I get is:

       

      Caused by: java.lang.RuntimeException: unable to execute Action

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

       

      Send Task was the old workItemHandler (in the example), the new one would be MyServiceTaskHandler:

       

      Under Eclipse -> Properties, Action for this intermediateThrowEvent I found this:

       

      org.drools.process.instance.impl.WorkItemImpl workItem = new org.drools.process.instance.impl.WorkItemImpl();
      workItem.setName("Send Task");
      

       

      If I change this to:

      org.drools.process.instance.impl.WorkItemImpl workItem = new org.drools.process.instance.impl.WorkItemImpl();
      workItem.setName("MyServiceTaskHandler");
      
      It changes it back to Send Task immediately when I run the processTest.java. So where exactly is that fetched

       

       

      This is the work definition:

       

      import org.drools.process.core.datatype.impl.type.ObjectDataType;
      import org.drools.process.core.datatype.impl.type.StringDataType;
      
      [
        [
          "name" : "MyServiceTask",
          "parameters" : [
              "Message" : new StringDataType()
          ],
          "displayName" : "MyServiceTask",
          "icon" : "icons/arrowright.GIF"
        ]
      ]
      

       

       

      This the java in my processTest:

       

      KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
      kbuilder.add(ResourceFactory.newClassPathResource("StartProcessWithMessage.bpmn2"), ResourceType.BPMN2);
      KnowledgeBase kbase = kbuilder.newKnowledgeBase();
      
      StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
      ksession.getWorkItemManager().registerWorkItemHandler("MyServiceTask", new MyServiceTaskHandler());
      

       

       

      Thx for your help.

       

      Tobi

        • 1. Re: Could not find work item handler
          tomcheng76
          • 2. Re: Could not find work item handler
            roxy1987

            You need to add a work item handler for the task.

             

            eg. if it is a human task, WorkItemHandler is added like this :

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

             

            if it is mail node, then WorkItemHandler is defined like this :

            ksession.getWorkItemManager().registerWorkItemHandler("Email", new SystemOutWorkItemHandler());

             

            regards.

            • 3. Re: Could not find work item handler
              tob1as

              Thanks for your help.

               

              I did that before, like this:

               

              ksession.getWorkItemManager().registerWorkItemHandler("MyServiceTask", new MyServiceTaskHandler());

               

              I also wrote the handler class. However, it is still looking for the wrong handler.

               

              When I open the bpmn file in eclipse and check for the connected action entry for this particular task, it shows

               

              org.drools.process.instance.impl.WorkItemImpl workItem = new org.drools.process.instance.impl.WorkItemImpl();
              workItem.setName("Send Task");

               

              When I change the setName function to MyServiceTask and reopen the bpmn file, it changes it back. So it must fetch this from somewhere ...

              • 4. Re: Could not find work item handler
                roxy1987

                Yeah. Sounds about right. I may have to get back on that.

                 

                Regards.

                • 5. Re: Could not find work item handler
                  tob1as

                  Could it be, that the intermediate throw event has to be registered for "Send Task" ?

                   

                  //This works

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

                   

                  //This works

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

                   

                  //Does not work

                  ksession.getWorkItemManager().registerWorkItemHandler("Blub!", new MyOwnIntermediateThrowHandler());