Archive for the 'English' Category

jBPM 5.0 – creating simple Human Tasks with variables

The fastest way to get jBPM 5.0 running is to take these three simple steps:

1. Download the jBPM 5.0 installer:
2. Run ant install.demo
3. Once everything is downloaded, run ant start.demo

Start off by creating a new BPMN file. To do so, select File->New->File, as the filename input “YourProcessName.bpmn” (thanks to the extension the Process Editor will open).

Inside the editor, create the business logic that you desire.

For this example I have created a process that looks like this:

I used two Script Tasks to set the variables and two User Tasks.
Script tasks are necessary because a Human Task can have only a single input parameter, “Content”.
To pass multiple variables “Content” must be set to a map that contains all the variables.

Begin by opening the properties tab of the project.
If you cannot see the properties view, open it using the menu “Window”, then “Show View” and “Other…”, and under the “General” folder select the Properties View.
Set the projects Id, Name, Package and variables (click on the “…” button in the Value section).
The map field should be a object type with its classname set to java.util.HashMap.
The other fields should be set to strings.
The end result should look like this:


Select the first Script task and open its properties tab.
Open the Action editor for the Action field (click on the “…” button in the Value section).
Set the dialect to Java.

Create a map and add the necessary variables:

map = new java.util.HashMap();

map.put("name","John Doe");

kcontext.setVariable("map", map);

The last three lines of this Action create globally accessible data stored in the Knowledge Session.

Now open the properties view for the First User Task.
Set ActorId to “krisv”.
Open the parameter mapping editor and add a mapping:
Parameter = “Content”, Value = “map”
This will allow us to use variables inside the Human Task Form.
Open the result mapping editor and add a mapping of the returned values:
Parameter = “phoneNumber”, Value = “phoneNumber”
Parameter = “name”, Value = “name”
Set Skippable to “false” and TaskName to “TaskOne”
The task name is important because it connects the task with its form.

Open the properties of the second Script Task and add the necessary action:


Now open the properties view for the Second User Task.
Set ActorId to “john”.
Open the parameter mapping editor and add a mapping:
Parameter = “Content”, Value = “map”
Set Skippable to “false”, TaskName to “TaskTwo”.

Now its time to create the Human Task Forms.
jBPM 5.0 uses ftl forms which are basically HTML.

Create two files, TaskOne.ftl and TaskTwo.ftl.

Their sources should look accordingly:


<h2>First Task</h2>

Name: ${name}<br>
Phone Number: ${phoneNumber}
<form action="complete" method="post"
Name : <input name="name" type="text">
Phone number : <input name="phoneNumber" type="text">
<input value="Complete" type="submit"></form>



<h2>Task Two</h2>
Name: ${name} <br>
Phone Number: ${phoneNumber} <br>

<form action="complete" method="POST" enctype="multipart/form-data">
<input type="submit" value="Complete">

Create a screenshot of the process diagram and save it as a png file with its name set to the process Id (in this case

Pack these three files (two .ftl files and a .png screenshot) into a .jar file.

There are two ways to deploy a process: by Guvnor or by hand.
The second option means that the .jar file has to be added to the servers classpath (jboss-dir/server/default/lib/),
and the .bpmn file has to be added to the directory where all bpmn files are stored – this directory is set in the ant build.xml file by the argument. The Default value is: ${install.home}/sample/evaluation/src/main/resources/.

When changes are made to the .ftl files, because the .jar is being added to the servers class path, the server has to be restarted.
When using the demo you can simply run ant stop.demo and ant start.demo.

When changes are made to the bpmn file, no restart is necessary. Just copy the new file to the appropriate directory and the
process will change accordingly.

When the deployment is completed, the task can be started.
There are two ways to accomplish this:
From the jBPM console or by an application.
Login into the jBPM console (localhost:8080/jbpm-console), go to Processes -> Process Overview, select the appropriate process and click “Start”.
Once the process has started you can login as krisv/krisv and view the human task form by selecting “view” for the appropriate task in the Personal Tasks tab.
Once you complete the form, login as john/john. The new variables you have entered should be visible in this users form.

The easiest way to start a task from an application is to create a jBPM project in Eclipse, select adding the Hello World example and slightly modify the code.
The final code should look like this:

package myproject;

import org.drools.KnowledgeBase;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.process.workitem.wsht.WSHumanTaskHandler;

* This is a sample file to launch a process.
public class ProcessTest {

public static final void main(String[] args) {
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());
// start a new process instance
} catch (Throwable t) {

private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("MyProcess.bpmn"), ResourceType.BPMN2);
return kbuilder.newKnowledgeBase();


Once this file is ran as a Java Application, the process starts and can be accessed via the jBPM console for the user krisv.

While learning the basics of jBPM I found very helpful information here:
1. Getting started with jBPM 5 screencast:
2. jBPM 5 Example – Human Task Forms with Variables:

Web Services with Eclipse, Tomcat, Axis, Rampart

This article is a part of a bigger document that has been created as a summary of my 3-month experience with IBM ESI.

Below you will find basic information about Web Services as well as a step-by-step tutorial ilustrating how to create and test:

– A simple Hello World Web Service
– A SSL-based Web Service
– A WS-Security enabled Web Service

With the use of:

– Eclipse
– Web Tools Platform
– Apache Tomcat
– Apache Axis
– Apache Rampart
– Eclipse Web Services Explorer
– SoapUI

Read more here

Language / Język