Search TWGer

Tuesday, August 4, 2009

JBPM 4.0 configuration for Eclipse workspace


During my JBPM exploration, I have encountered lot of difficulties in finding correct configuration information. Configuration issues makes you spend/waste more time which you could use more effectively to understand JBPM API. Here I am providing simple steps to configure your eclipse and run simple JBPM flow.

1. Download JBPM bundle from http://www.jboss.org/jbossjbpm/jbpm_downloads/

2. Extract the zip file to folder C:\JBPM-4.0 (I am assuming this as JBPM home directory you may name different)

3. To configure or work with JBPM it is necessary to have database and schema created for JBPM. Assuming you have database (any) installed (here I am considering mySQL database)

4. Create database jbpm4 in mySQL

5. Modify file C:\JBPM-4.0 \db\jdbc\mysql.properties so that it contains your database properties as below

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/jbpm4
jdbc.username=root
jdbc.password=admin123

6. Launch the following command:

C:\JBPM-4.0\db>ant -Ddatabase=mysql create.jbpm.schema

This should create JBPM tables in your database. And to add some sample data to the tables run following command

C:\JBPM-4.0\db>ant -Ddatabase=mysql load.example.identities

Those not having ant installed or not familiar with. Follow steps below.

a. Download latest version of ant from http://ant.apache.org/ .
b. Add bin directory of you ant installation to your path
c. Set the ANT_HOME environment variable to the directory where you installed Ant.
d. Optionally, set the JAVA_HOME environment variable. This should be set to the directory where your JDK is installed.
e. Type C:/>ant –version to verify the installation

Now you have to configure the location of your JBOSS server.

7. Download JBOSS version 5.0.0.GA stable version from http://www.jboss.org/jbossas/downloads/

8. Extract bundle, it should create JBOSS-5.0.0.GA

9. Modify build.xml file in jboss directory of JBPM home. Change jboss.home and jobss.version property as

property name="jboss.version" value="5.0.0.GA"
property name="jboss.home" value="C:\jboss-5.0.0.GA"



10. Run following command on your command prompt

C:\JBPM-4.0 \jboss>ant -Ddatabase=mysql install.jbpm.into.jboss

above should create a "jbpm" folder in your JBoss deploy directory


Now we are ready to move to IDE to try out some sample application using Eclipse platform.

If your eclipse does not have JBPM graphical designer following are the steps.

a. Start your eclipse, go to Help--> Software Updates -- > Available Software Tab -- > Click Add Site -- > In Add Site dialog box Click Archive
b. Select JBPM-4.0\gpd\jbpm-gpd-site.zip and click Open then OK.
c. Check newly added archive and click “Install” button.
d. Restart your eclipse IDE.

Above steps will install JBPM Graphic Designer plugin in your eclipse IDE. This did not work very well for me. I was getting out of memory error during the process in my Gynemade eclipse. You may want to close and start your eclipse with following command might help.

eclipse -vmargs -Xmx1024M

Create New Project in your eclipse IDE. Press Cntl + N or File -- > New …



Click Next -- > specify JBPM home directory and provide some meaningful name for the JBPM runtime -- > Click Next -- > OK


You will see Project created in your workspace as


-->
You will see multiple packages created in your workspace such as src/main/java, src/main/config, jpdl etc. I do not need to explain what is that for package name of the packages tells what is what.

Now lets create new New jpdl file.





Double click test.jpd.xml and create your first process using component tools on the left side of the graphical editor.



Click Source tab to view or modify xml for the test.jpdl.xml file. Add class name and method name for the Java task we defined in the graphical editor. You can also specify class attribute in the property pane of the IDE.

(Click on image for clear view of the text)



Also, create class Test.java in package com.test



--> Create another class name JBPMTest.java to test the process flow we have designed above in the same package com.test


Before you go further make sure you have your jbpm.cfg.xml and jbpm.hibernate.cfg.xml file in your bin directory



For now keep your jbpm.cfg.xml to the minimum as...



-->
And your jbpm.hibernate.cfg.xml file having entry for your mysql database details as



Run JBPMTest as a java application. You should see your first JBPM flow working in the console as below. Of course to understand JBPM more you need to read JBPM API documentation here … http://docs.jboss.org/jbpm/v4.0/javadocs/index.html?org/jbpm/api/IdentityService.html



Cheers!!!

3 comments:

  1. I followed the step exactly as they are listed but when I try to create a new project I don't see the "Process Project" item. Only jBPM Process Definition is listed there. What I might be doing wrong?
    I am using eclipse3.6 and jBPM-4.4.
    Thanks
    TS

    ReplyDelete
  2. Hi Bhupesh,
    Nice Job. It is very useful for me and simple than the user guide given by JBPM4.0. Good Job keep it up.

    Thanks
    Muthu

    ReplyDelete
  3. Helpful but bit old information. Please update.

    Thanks,
    Sloan

    ReplyDelete