| 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.
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.
|
| 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:

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:

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.

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.

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
| Comments |
|


