9 Replies Latest reply on Nov 27, 2012 6:42 AM by Laura delli Paoli

    Handle Human Task with custom HumanTaskHandler

    Laura delli Paoli Master

      Hello everybody,

      I was trying to run a human task with a custom handler, but my handler doesn't work.

      Can anyone help me?





      public class TestHumanTask {



                public static final void main(String[] args) throws Exception {


                          // load up the knowledge base

                          KnowledgeBase kbase = readKnowledgeBase();

                          StatefulKnowledgeSession ksession = JBPMHelper.newStatefulKnowledgeSession(kbase);

                          //StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

                          CommandHumanTaskHandler handler = new CommandHumanTaskHandler();

                          ksession.getWorkItemManager().registerWorkItemHandler("RunAction", handler);



                          // start a new process instance


                          System.out.println("Process started ...");




                private static KnowledgeBase readKnowledgeBase() throws Exception {

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

                          kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);

                          return kbuilder.newKnowledgeBase();



                private static void startUp() {



                          // please comment this line if you already have the task service running,

                          // for example when running the jbpm-installer






      public class CommandHumanTaskHandler extends HumanTaskHandler{



                private static final long serialVersionUID = 1L;


                public CommandHumanTaskHandler () {





                public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

                          //super.executeWorkItem(workItem, manager);


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



                public void complete(WorkItem workItem,  Map<String,Object> results){



                          //super.complete(workItem, results);





                public void abortWorkItem(WorkItem arg0, WorkItemManager arg1) {

                          // TODO Auto-generated method stub