Home JBpm JBPM 4 tutorial: installation
12 | 03 | 2010
JBoss 5 AS Book
"JBoss AS 5 development" reviews
Please share your feedback/review with other readers!
Banner
Dashboard
Advertise with Us
Banner
RSS Feed
Login
Sign here for the NewsLetter.



Poll
What book could be in your wish list next XMas ?
 
JBoss admin resources
Banner
JBPM Books
JBoss howto

How can you solve deployment errors caused by large war/jar/ear files ?

jboss recipe of the day ...
Read More

How do you configure your .war to be deployed after your EJB ?

jboss recipe of the day ...
Read More

How do I configure a Queue/Topic to work in a cluster?

JBoss recipe of the day ...
Read More
JBPM 4 tutorial: installation
Written by F.Marchioni   
 

A few days ago JBPM 4 CR1 has been release. In this tutorial you can get a preview on this amazing BPM solution, learning how to install the product on your JBoss AS.

JBPM 4 candidates as "state of the art" opensource workflow. As a matter of fact, the workflow engine has gono under substantial modifications. 
 

  •  Much improved docs, including a split between user guide and developers guide

  •  BPMN based graphical designer in eclipse

  •  Command based services as the primary client API

  •  Decoupled activity implementation API

  •  Multiple execution modes

  •  Improved multiple language support

  •  Easy addition of custom activities

  •  DB evolution improvements

  •  DB partitioning per process language

In this tutorial you'll learn how to install JBPM 4 into your JBoss AS, how to setup your DB schema configuration and, finally, how to deploy a sample JBPM application.
 


Step 1: Download JBPM 4

Donwload the latest JBPM 4 CR from http://www.jboss.org/jbossjbpm/jbpm_downloads/

Unzip the archive (Approx 70 MB)

Exploding the archive will produce the following structure.  

11/06/2009  08.32    <DIR>          db
11/06/2009  08.32    <DIR>          doc
11/06/2009  08.51    <DIR>          downloads
11/06/2009  11.22    <DIR>          examples
11/06/2009  08.32    <DIR>          gpd
11/06/2009  11.17    <DIR>          jboss
11/06/2009  08.33    <DIR>          src
11/06/2009  08.33    <DIR>          lib
04/06/2009  14.09             8.102  jboss.eula.txt
05/06/2009  10.29           811.259 jbpm.jar
04/06/2009  14.09            26.430  license.txt
05/06/2009  10.21            22.996  readme.html

This is a short explanation on the single directories/files:  

  • db: DB schema creation scripts

  • doc: User guide, javadocs and developers guide

  • examples: Example processes that are used in the user guide

  • gpd: Graphical process designer plugin as an eclipse archived site

  • jboss: JBoss installer to install jBPM into JBoss

  • lib: Third party libs and some special jBPM libraries

  • src: Sources

  • jbpm.jar: The jBPM main library archive

Step 2: install the JBPM schema.

We will show how to install JBPM schema into a MySQL database.

At first, create a schema named "jbpm4" on your local MySQL database. Then add an user named "jboss" to the database.

CREATE DATABASE jbpm4;

GRANT ALL PRIVILEGES ON *.* TO
jboss@localhost
    ->   IDENTIFIED BY 'jboss' WITH GRANT OPTION;


Then edit the file JBPM4_HOME\db\jdbc\mysql.properties so that it contains our database properties:

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


Now move the the "db" folder where you will find a build.xml. Launch the following command:

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

This will create the JBPM tables in your schema. You can verify from your MySQL client that your DB schema is now set up:

 jbpm 4 tutorial
Now add some sample data in your schema which will be necessary for logging into the console:

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

Step 3: Install JBPM on JBoss

You have to configure the location of your JBoss AS. Move into the "jboss" folder and open the ant build.xml file.

Configure the following properties, at the top of the file:

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


Now launch the following ant task:

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

This will create a "jbpm" folder in your JBoss deploy directory:

jbpm4 tutorial
 

Step 4: Install the Graphic designer

The graphical designer is bundled into JBPM 4 distribution into the directory gpd. The filename is jbpm-gpd-site.zip. You can install it from the Menu: Help | Software Updates. Select "Add Site" option and then point at the jbpm-gpd-site.zip with the "Archive" option.

jbpm 4 tutorial

We will deploy a simple web application which contains barely a JSP and a process definition file. The process definition file is taken from JBPM 4 examples distribution:  

<?xml version="1.0" encoding="UTF-8"?>

<process name="DecisionExpression" xmlns="http://jbpm.org/4.0/jpdl">

  <start g="16,102,48,48">
    <transition to="evaluate document"/>
  </start>

  <decision name="evaluate document" expr="#{content}" g="96,102,48,48">
    <transition name="good" to="submit document" g="120,60:-36,23" />
    <transition name="bad"  to="try again" g=":-15,-21" />
    <transition name="ugly" to="give up" g="120,189:-35,-41" />
  </decision>

  <state name="submit document" g="175,35,122,52" />
  <state name="try again" g="176,100,122,52" />
  <state name="give up" g="177,164,122,52" />

</process>

In this process we simply illustrate a transition to a decision node. The decision node choose the workflow path depending on the "content" process variable.

jbpm4 workflow

Add to your Web project a simple index.jsp file which deploys the process definition and create a new instance of the process, setting the "content" variable to "good" using an HashMap.

<%@ page import="org.jbpm.api.*, java.util.*" %> 

<%

   ProcessEngine processEngine = new Configuration()
	      .buildProcessEngine();

   RepositoryService repositoryService = processEngine.getRepositoryService();
   ExecutionService executionService = processEngine.getExecutionService();

   long deploymentDbid = repositoryService.createDeployment()
        .addResourceFromClasspath("sample-process.jpdl.xml")
        .deploy();
		
   Map<String, Object> variables = new HashMap<String, Object>();
   variables.put("content", "good");
	    
   ProcessInstance processInstance = executionService.startProcessInstanceByKey("DecisionExpression", variables);
   out.println("Process reached state " + processInstance.getState());
   
%>

This is a tree view of your web project. As you can see you don't need to add any library to your web application because they are already bundled in the "jbpm" folder.

jbpmtest.war
¦   index.jsp
¦
+---WEB-INF
   ¦   web.xml
   ¦
   +---classes
      
sample-process.jpdl.xml

Deploy it on JBoss 5 and verify that the process reached the state "submit document".

As you can see the JBPM 4 api is quite different. Interacting with jBPM occurs through services. The service interfaces can be obtained from the ProcessEngine  which is build from a Configuration.  

In the second tutorial we will cover in detail the new JBPM 4 interfaces which are used to interact with JBPM 4. Following, we will cover in a third tutorial the new activities and nodes added with JBPM 4.

Stay tuned!

References:

JBPM 4 User Guide
First release of JBPM 4


JBoss.org Search
Custom Search
Comments
Search
Only registered users can write comments!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."