0 Replies Latest reply on Mar 28, 2018 12:04 PM by Rafael Detoni

    Custom Work Item Handler

    Rafael Detoni Newbie

      Hi everyone,

       

          I am very confusion about how to create a custom work item handler, I find so many diferent materials about how to create and none worked for me. I am very frusted with that I hope that you guys can help me!

       

      My principal reference was this blog and this video:

      Blog: FXApps: Creating custom Work Item Handler in BPM Suite/jBPM 6

      Youtube: jBPM6.3 - Creating Service Task - YouTube

       

      My steps was:

       

      1) Get the code from github and export to jar in a eclipse:

      GitHub - jesuino/hello-world-work-item-handler: The simples Work Item Handler as described here: http://fxapps.blogspot.…

       

      public class HelloWorkItemHandler implements WorkItemHandler {
      
      
      public void abortWorkItem(WorkItem wi, WorkItemManager wim) {
      System.out.println("Oh no, my item aborted..");
      
      
      }
      
      
      public void executeWorkItem(WorkItem wi, WorkItemManager wim) {
      System.out.println("Hello World!");
      wim.completeWorkItem(wi.getId(), null);
      }
      
      
      }

       

      I saw here that in this example don't have kmodule.xml, is this right? Or I have to configure the application and the kmodule.xml in the META-INF?

       

      2) To import this jar in the application I was reading that was necessary to put the jar in:

       

      jbpm-gwt-console-server.war/WEB-INF/lib or

      C:\CivitasProcessos\jbpm\dependencies or

      Configure this in the repository like: Tools -> Project Editor -> Project Settings -> select Dependencies. Add from repository and them configure the kbase and ksession

       

      What is the correct configuration?

       

      3) I had to configure the WorkDefinition and i saw two configuration for that

      New Item -> Business Process -> WorkDefinitions

       

      [

         "name" : "HelloWorkItemHandler",

          "displayName" : "Hello World!",

          "icon" : "defaultemailicon.gif"

      ]

       

      OR

       

      [

          "name" : "HelloWorld",

          "description" : "Prints hello World in the console",

          "displayName" : "Hello World!",

          "defaultHandler" : "mvel: new org.jugvale.jbpm.workitemhandler.HelloWorkItemHandler()",

          "mavenDependencies" : [

                "org.jugvale.jbpm.workitemhandler:hello-workitemhandler:1.0"

           ]

      ]

       

      4) In the Build and Deploy I have this error:

       

      Deployment of unit Imagem:CustomHandlerTask:1.0 failed: java.lang.RuntimeException: java.lang.IllegalStateException: Cannot find ksession, either it does not exist or there are multiple default ksession in kmodule.xml

       

      If I remove the configuration from kbase and ksession I can deploy but the processes definition dont appear!

       

      I appreciate any kind of help.