1 2 Previous Next 17 Replies Latest reply on Dec 5, 2015 3:30 PM by np97190

    jBPM Console Server can't find WorkItem Handler Implementation

    theom3ga

      Hi there.

       

      I'm having a problem trying to run a process that has a Work Item. The server can't find the implementation for the Work Item Handler. These are the steps I follow.

       

      First I create the work item in drools-guvnor, it is called 'Activo1', and it's defined as follows:

       

      import org.drools.process.core.datatype.impl.type.ObjectDataType;

      import org.drools.process.core.datatype.impl.type.StringDataType;

       

      [

          [

          "name" : "Activo1",

          "parameters" : [

                    "MyFirstParam" : new StringDataType(),

          ],

          "results" : [

              "Result" : new StringDataType()

          ],

          "displayName" : "My Task",

          "icon" : "",

        ]

      ]

       

       

      Then, I create a simple process with a start event, the work item, and the end event. I build a snapshot of the package and the process appears in the list of available processes in the jbpm-console.

       

      Next, I edit the conf/META-INF/CustomWorkItemHandlers.conf so it looks like this:

      [

        "Log": new org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler(),

        "Activo1": new defaultPackage.Activo1()

      ]

       

      I use ant stop.demo, and then ant start.demo, then I check in the console server war that the CustomWorkItemHandlers file is properly updated. So far it's ok.

       

      For the implementation, I created a folder called 'defaultPackage' and, inside, I create an Activo1.java file with the following contents:

       

      package defaultPackage;

       

      import org.drools.runtime.process.*;

       

      public class Activo1 implements WorkItemHandler{

       

          public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

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

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

          }

       

          public void abortWorkItem (WorkItem workItem, WorkItemManager manager) {

              // Nothing

          }

      }

       

      In order to compile it, I use

      javac -cp "runtime/lib/*" defaultPackage/Activo1.java

       

      And in order to create the JAR file I use this:

      jar cfe Activo1.jar defaultPackage.Activo1 defaultPackage

       

      The previous two commands may be the part that's wrong, because I'm an absolute java noob.

       

      I copy the JAR file in all the 'lib' folders I come across, namely $installer/lib, $installer/runtime/lib and $installer/jboss[...]/standalone/lib.

       

      When I launch the process in the jbpm console, I get the following error in the SERVER.LOG file:

      Could not commit session: org.jbpm.workflow.instance.WorkflowRuntimeException: [defaultPackage.Proceso1:4 - My Task:2] -- Could not find work item handler for Activo1

       

      HOWEVER, If I change the CustomWorkItemHandlers.conf file so it looks like this:

      [

        "Log": new org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler(),

        "Activo1": new org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler()

      ]

       

      and then I launch the process, the default SystemOut work item handler works OK and I get the following in the LOG file:

      [stdout] (http-localhost-127.0.0.1-8080-1) Executing work item WorkItem 5 [name=Activo1, state=0, processInstanceId=5, parameters{TaskName=Activo1}]

       

      So the work item definition and the model definition seem to be OK. The problem seems to be in the place or the way the JAR was generated.

       

      Please help!

        • 1. Re: jBPM Console Server can't find WorkItem Handler Implementation
          ashu.itbhu

          In you processmain java file you have to register the handler like this

           

          ksession.getWorkItemManager().registerWorkItemHandler(
                 "Activo1", new defaultPackage.Activo1());

           

          Hope this will help you to some extent...

          • 2. Re: jBPM Console Server can't find WorkItem Handler Implementation
            theom3ga

            As I stated, I want to launch the process from the console. I don't have any ProcessMain java file or any other java file other than the WorkItemHandler Implementation.

            • 3. Re: jBPM Console Server can't find WorkItem Handler Implementation
              swiderski.maciej

              you need to put your custom jar inside jbpm-gwt-console-server.war/WEB-INF/lib so it will be found on runtime. Alternatively you can drop it in jbpm-installer/dependencies and rerun installation so it will get included automatically.

               

              HTH

              1 of 2 people found this helpful
              • 4. Re: jBPM Console Server can't find WorkItem Handler Implementation
                theom3ga

                I thought it would be possible to change the files in runtime so I don't have to be stopping and rebuilding the server every time...

                • 5. Re: jBPM Console Server can't find WorkItem Handler Implementation
                  theom3ga

                  So... is it definitely impossible to modify the JAR in runtime?

                  • 6. Re: jBPM Console Server can't find WorkItem Handler Implementation
                    ashu.itbhu

                    In my application i have implemented a WI handler for all my DB integrations. This is working fine in general but not in one case.

                     

                    1. Lets say WI config i have sth as return type defined

                     

                    "results" : [

                         "DB_OPS" : new ObjectDataType("com.sample.Employee")

                    ]

                     

                    2. In process i have defined a vaiable employee as Object(com.sample.Employee)

                     

                    3. In WI handler class i have sth like

                     

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

                    Employee employee = new Employee()
                    employee.setFirstName("Joe");

                    outputMap.put("DB_OPS" , (Object) employee);

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

                     

                    4. This is throwing error while setting value in bean ie doing operation employee.setFirstName("Joe");

                    5. Error :"APPLICATION ERROR: transaction still active in request with status 0"

                     

                     

                     

                     

                     

                    • 7. Re: jBPM Console Server can't find WorkItem Handler Implementation
                      stephan_p

                      I had the same problem recently and like to share my solution because it took me a lot of time to figure it out.

                       

                      1. Extract the jbpm-gwt-console-server.war

                      Extract the jbpm-gwt-console-server.war in <server>/standalone/deployments/ (with 7zip), make sure the directory name is jbpm-gwt-console-server.war. Remove the jbpm-gwt-console-server.war file from the directory. Start the server and test if the console is correctly deployed. If not re the README.txt in the deployments folder and create a jbpm-gwt-console-server.war.dodeploy file

                       

                      2. Create .jars of your custom work item handlers

                      If you are using Eclipse you can simply right click one the file you want to have in the jar an click export. The choose "JAR file" and in the next step select all the classes you want to include. Place your *.jar files in <server>/standalone/deployments/jbpm-gwt-console-server.war/WEB-INF/lib

                       

                      3. publicize your config files to the console

                      Put your drools.rulebase.conf, drools.session.conf, workItemHandlers.conf etc. in the <server>/standalone/deployments/jbpm-gwt-console-server.war/WEB-INF/classes/META-INF so they can be found by the console. Redeploy the console-server and try to start the workflow.

                      As pointed out by Maciej Swiderski in the post below it is better to use the a session template to register your custom work item handler. To do so copy default.session.template file from <server>/standalone/deployments/jbpm-gwt-console-server.war/WEB-INF/classes/ to /standalone/configuration/ and rename it to session.template. In this way it gets loaded automatically. Edit the workItemHandlers section to your needs. Example:

                       

                      new SessionTemplate().{  
                          businessKey = "jbpm/consolesession",
                          imported = false,
                          persistenceUnit = "org.jbpm.persistence.jpa",
                          
                          properties = ["drools.processInstanceManagerFactory":"org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory",
                                        "drools.processSignalManagerFactory" : "org.jbpm.persistence.processinstance.JPASignalManagerFactory"  
                                          ],
                                          
                          workItemHandlers = ["Human Task" : "new org.jbpm.process.workitem.wsht.AsyncHornetQHTWorkItemHandler(\"jbpmConsoleHTHandler\", taskClient, ksession, org.jbpm.task.utils.OnErrorAction.LOG)",
                                              "Service Task" : "new org.jbpm.process.workitem.bpmn2.ServiceTaskHandler(ksession)",
                                               "CustomWorkItemHandler": "new my.package.CustomWorkItemHandler(ksession)"],
                                              
                          eventListeners = ["new org.jbpm.process.audit.JPAWorkingMemoryDbLogger(ksession)",
                                            "new org.jbpm.integration.console.listeners.TriggerRulesEventListener(ksession)"  ]
                      };
                      
                      

                       

                      Do not forget the quotation marks or you might get an error when you pass the ksession to the constructor of your WorkItemHandler.

                       

                      Please test this and watch server.log for problems (maybe I have forgotten something).

                       

                      Hope this helps someone

                      • 8. Re: jBPM Console Server can't find WorkItem Handler Implementation
                        swiderski.maciej

                        Thanks a lot for this Stephan!

                         

                        Just one comment about point 3, you could use session template config file to register handler, event listeners etc, check out documentation on this, might be easier to work with console. But jars with custom classes must be placed within console-server.war as you described.

                         

                        Cheers

                        • 9. Re: jBPM Console Server can't find WorkItem Handler Implementation
                          stephan_p

                          Thanks for the help, I edited my post above. Do you know if there is a posibility to add custom work item handlers via the guvnor repository? So i don't have to edit the session template every time and can keep the config in one place.

                          • 10. Re: jBPM Console Server can't find WorkItem Handler Implementation
                            alvinuw

                            Hi Ashutosh Kumar,

                             

                            Did you solve the APPLICATION ERROR: transaction still active in request with status 0.

                            I have the same error, but don't "Console Server can't find WorkItem Handler Implementation" error.

                            In my handler, I have

                             

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

                            results.put("MsgId", id);

                            results.put("Checker", recipient);

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

                             

                            Both "MsgId" and "Checker" are variables of the process.

                             

                            Any suggestions are appreciated.

                            Thanks.

                            • 11. Re: jBPM Console Server can't find WorkItem Handler Implementation
                              dmwpepper

                              Hi Maciej,

                               

                              Could you produce a complete tutorial on how to deploy a process that contains Java code and work items from the web Process Designer.   We're all trying a bunch of different things, thinking/hoping that they work.  Many of us are not getting our questions answered on this.  It would help if the tutorial had some screen shots instead of just text.

                               

                              This appears to be an easy process and probably is, but a bunch of people are spending a lot of time trying to figure it out and a straightforward description would save us a lot of time. What do you think?

                              • 12. Re: jBPM Console Server can't find WorkItem Handler Implementation
                                swiderski.maciej

                                David, I beliee you have quite complete description here but that might be anyway to capture all that insngle documentation/blog page. Could you please fine a jira (documentation) issue for this?

                                 

                                Cheers

                                • 13. Re: jBPM Console Server can't find WorkItem Handler Implementation
                                  alvinuw

                                  Hi Maciej,

                                   

                                  Do you have any idea about this error "APPLICATION ERROR: transaction still active in request with status 0."?

                                  Thank you.

                                  • 14. Re: jBPM Console Server can't find WorkItem Handler Implementation
                                    swiderski.maciej

                                    alvinuw, please open new thread for new question and provide as much details as you have to help with problem analysis.

                                     

                                    Cheers

                                    1 2 Previous Next