A few days ago JBPM 4 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 from http://sourceforge.net/projects/jbpm/files/
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
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:
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:
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 4 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:
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.
Step 5: deploy a simple process
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:
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.
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.
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.
JBPM 4 User Guide
First release of JBPM 4