Skip navigation

Here is example that shows how to use Local Human Task for task sevice in a web application instead of using task service based on Mina server.

This blog uses the same example shown in http://community.jboss.org/people/bpmn2user/blog/2011/09/21/jbpm5-web-example.

 

 

 

bpmn2diag.png

 

This example has the following files as shown below.

 

TaskProcessServlet performs various actions (such as retrieving and completing the tasks etc) using the JBPM API (JbpmAPIUtil).

 

  directory.PNG

It should also be noted that this example uses 'DefaultUserGroupCallbackImpl' for user group managemnet. Any custom user group managemnt, such as LDAP etc, can be used.

 

UserCallback.PNG

 

Here is the sample code to create the task service using Local Human Task.

 

humantaskcode.PNG

How to run and deploy in web container, e.g., Tomcat?

 

Use maven to create a war file (e.g., mvn package) and copy the war file to TOMCAT_HOME/webapps

 

A successful deployment shows the following page (e.g., http://localhost:8080/jbpm5webexample/)

 

mainscr.png

A process instance can be created by selecting 'CreateProcess' button.

 

procReq.png

The tasks for the first user can be retrieved by selectig the button 'Select User'.

selectuser.bmp

 

After completing the task as the first user, krisv, it would wait at the second task, that needs to be approved by 'john'.

detail.bmp

johnapprove.bmp

 

 

It is also required to set datasource JNDI.

Refer to http://community.jboss.org/people/bpmn2user/blog/2011/01/21/test for the settings in Tomcat.

 

Here are the main steps:

1.) Copy the following libraries to TOMCAT_HOME/lib

 

btm-1.3.1.jar

btm-tomcat55-lifecycle-1.3.3.jar

slf4j-api-1.5.2.jar

slf4j-jdk14-1.5.2.jar

btm-1.3.1.jar

jta-1.1.jar

h2-1.3.155.jar

 

a.) Create the following btm-config.properties in TOMCAT_HOME/conf

 

bitronix.tm.serverId=tomcat-btm-node0

bitronix.tm.journal.disk.logPart1Filename=${btm.root}/work/btm1.tlog

bitronix.tm.journal.disk.logPart2Filename=${btm.root}/work/btm2.tlog

bitronix.tm.resource.configuration=${btm.root}/conf/resources.properties

 

    b.) Add transaction and Resource information after 'WatchedResource' line in TOMCAT_HOME/conf/context.xml as shown below.

.........

..........

<WatchedResource>WEB-INF/web.xml</WatchedResource>

    <Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory" />

 

    <Resource name="jdbc/jbpm-ds" auth="Container" type="javax.sql.DataSource"

               maxActive="15" maxIdle="2" maxWait="10000"

logAbandoned="true"

               username="sa" password=""

driverClassName="org.h2.jdbcx.JdbcDataSource"

               url="jdbc:h2:tcp://localhost/~/test"/>

..........

.........

 

c.) Create 'resource.properties' in TOMCAT_HOME/conf as shown below.

 

resource.ds1.className=bitronix.tm.resource.jdbc.lrc.LrcXADataSource

resource.ds1.uniqueName=jdbc/testDS1

resource.ds1.minPoolSize=0

resource.ds1.maxPoolSize=5

resource.ds1.driverProperties.driverClassName=org.h2.jdbcx.JdbcDataSource

 

d.) Modify TOMCAT_HOME/conf/server.xml to include BTMLifecycleListener after the line that has GlobalResourcesLifecycleListener as shown below.

 

.........

<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <Listener className="bitronix.tm.integration.tomcat55.BTMLifecycleListener" />

 

 

Update: This example has been updated for the version 5.4 and the modified code is included in the following attachment jbpm5.4webexample.zip.

A local version of task service (LocalTaskService) is supported in the version 5.4 and it is integrated with the transaction of the process engine.

 

localtask.PNG

Filter Blog

By date:
By tag: