Thursday, August 16, 2007

Setup jBPM

jBPM is supposed to be a very strong workflow engine and significant tool in the graph oriented programming model. There is a lot of documentation available on jBoss's sites and wikis about this.

Here are some simple steps to get jBPM setup. These steps are for programmers new to jBPM, who want to cut thru the chase of reading the first 3 chapters, get into programming and then later get the funda's.
  1. Download jBPM suite from jBoss. Note the 'suite' as thats the package that contains 'everything' needed to get going with jBPM. Even if you are having the latest version of Eclipse or JBoss or Tomcat, don't think of following instructions on that to setup jBPM. It's not worth the effort. Just download.... jbpm-jpdl-suite-3.2.1.zip.
  2. The Eclipse designer plugin is included in the zip. To get that working, download the 3.2.1 version of Eclipse. Not a version more, not a version less. I have tried in both...there is something or the other that breaks. In the Europa build, i had wst broken after the designer upgrade.
  3. Extract eclipse in the jbpm/designer/eclipse folder. That folder is preconfigured for the eclipse-SDK-3.2.1-win32.zip.
  4. The installed jboss (embedded hsqldb) can be started from jbpm/server/start.bat
  5. We can now perform the steps given in the jBPM demo on jBoss at http://docs.jboss.com/jbpm/v3/demos/movies/jbpm-overview.htm

Ok, so we are set and can now test whether it will compile or not.

  1. Put the processdefinition.xml file, created above by the eclipse designer, where you will be putting the class file or put it in some directory on the classpath.

  2. Create a java file

    package trial;
    import org.jbpm.graph.def.ProcessDefinition;
    import org.jbpm.graph.exe.ProcessInstance;
    import org.jbpm.graph.exe.Token;
    public class SecondTrial
    {
    static ProcessDefinition process =
    ProcessDefinition.parseXmlInputStream(
    SecondTrial.class.getResourceAsStream(
    "processdefinition.xml"));
    public static void main(String[] args)
    {
    ProcessInstance processInstance =
    new ProcessInstance(process);
    Token token = processInstance.getRootToken();
    System.out.println(token);
    }
    }


  3. Create the build.xml file for ant (unformatted)

    <?xml version="1.0" encoding="UTF-8"?>
    <project default="all" basedir=".">
    <target name="init">
    <property name="webinf" value="WEB-INF">
    <property name="basedir" value=".">
    <property name="dirs.base" value="${basedir}">
    <property name="src" value="${dirs.base}/src">
    <property name="web" value="${dirs.base}/webcontent">
    <property name="classdir" value="${dirs.base}/WEB-INF/classes">
    <property name="libdir" value="${dirs.base}/WEB-INF/lib">
    <property name="libbase" value="F:/delme/jbpm-jpdl-3.2.1">
    </target>
    <target name="build">
    <javac srcdir="${src}" destdir="${classdir}" debug="true" includes="**/*.java" classpath="${libbase}/jbpm-jpdl.jar">
    </target>
    </project>


  4. Now run the java code using

    set CLASSPATH=F:\delme\jbpm-jpdl-3.2.1\jbpm-jpdl.jar;.;
    F:\delme\jbpm-jpdl-3.2.1\lib\commons-logging.jar;
    F:\delme\jbpm-jpdl-3.2.1\lib\dom4j.jar

    java trial.SecondTrial

Notes:
  1. The processdefinition.xml file should be in the classpath. I had a . (dot) in the classpath which is why I put the xml just besides by .class file. In a typical web environment, there will be more than one processdefinition.xmls stored in the DB. If at all they are in memory for some insane reason, make sure you have it in the classpath eg: WEB-INF/classes.

That should do it. Programmers ... lets roll.

No comments :

Powered by Blogger.