2 Replies Latest reply on Sep 27, 2012 9:14 AM by Reza Ghalavand

    WorkItemHandler Deployment Problem

    Reza Ghalavand Newbie

      Hi everyone,

       

      I'm new to JBoss. I've been using demo installer for a few days testing it, and right now I'm trying to register a workitemhandler of my own.

      so far I've edited CustomWorkItemHandlers.conf in notepad just as everyone says and made a WorkItemHandler class.

       

      here's my CustomWorkItemHandlers.conf:

       

      [

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

        "MyLog": new com.myTask.MyTaskHandler(),

      ]

       

      and here's the WorkItemHandler class itself in java:

       

      package com.myTask;

       

      import java.io.FileWriter;

      import java.io.IOException;

      import org.drools.runtime.process.WorkItem;

      import org.drools.runtime.process.WorkItemHandler;

      import org.drools.runtime.process.WorkItemManager;

       

      public class MyTaskHandler implements WorkItemHandler {

       

                @Override

                public void abortWorkItem(WorkItem arg0, WorkItemManager arg1) {

           }

       

       

                @Override

                public void executeWorkItem(WorkItem arg0, WorkItemManager arg1) {

                          FileWriter out;

                          try {

                                    out = new FileWriter("C:\\out.txt");

                                    out.write("Greetings from handler!");

                                    out.close();

                          } catch (IOException e) {

                                    e.printStackTrace();

                          }

           }

      }

       

      the problem is I have no prior experience with JBoss AS (nor with any other Java AS) and I have difficulty figuring out where to actually put my jar file so it gets deployed correctly. it's hard to tell because demo installer uses temproary folders which get deleted each time I stop/restart server. I'm kind of confused.

       

      thanks in advance

      PS: It's jBPM 5.3.0

        • 1. Re: WorkItemHandler Deployment Problem
          Tihomir Surdilovic Master

          jBPM installer makes this easy - you have to jar up your workitem handler implementations and place the jar(s) in the $installer/dependencies directory, then run

           

          ant clean.demo

          ant install.demo.noeclipse (or ant install.demo)

          ant start.demo.noeclipse (or ant start.demo)

           

          and it will be correctly placed on the classpath for you.

           

          HTH

          • 2. Re: WorkItemHandler Deployment Problem
            Reza Ghalavand Newbie

            Thanks dear Tihomir, I had already figured this out.

             

            Thanks to your only and 2 days late reply , I had time and opportunity to learn a few app server tricks. exploded war deployment and stuff...

             

            but there are more questions coming out each time I learn something new. for example some people say just deploy your jars to app server's classpath located at server/{profile}/lib, while some other say you should use exploded war method and put jars in WEB-INF/lib directory for exploded jbpm-gwt-console-server.war. Can u please tell what's the real difference?

             

            Thanks Tihomir