Small steps with big feet
Tutorial: Running the BPMN 2.0 Hello World example on MySQL (with Maven)
Last week, I showed you how to get a ‘BPMN 2.0 Hello World’ up and running with the latest release of Activiti. Today, we’ll take the very same example a step further and make it run on MySQL and mavenize it all.
Interested in just the code? Just scroll down to the bottom of the post or click here.
Prerequisites
The required stuff remains the same: Eclipse (or any other IDE) with a Maven plugin (I’m using m2eclipse), Java and Ant.
Project creation
We’re just creating a vanilla Maven project. I’ve used the Eclipse wizard (New -> Maven Project), but some commandline-magic should also do the trick.The end result should look like this in Eclipse:

Dependencies
To run our Hello World example on MySQL, we’ll need two dependencies:
- The Activiti engine jar, obviously
- The MySQL database driver
Accordingly, the pom.xml looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.jorambarrez.tutorial</groupId>
<artifactId>helloworld</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>5.0.alpha4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.13</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>activiti.repo</id>
<url>http://maven.alfresco.com/nexus/content/repositories/activiti/</url>
</repository>
</repositories>
</project>
The process
The Hello world process is the same as the one we’ve used in the previous article.

The corresponding XML also remains the same. Call it hello-world.bpmn20.xml and add it to src/main/resources.
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
targetNamespace="http://www.activiti.org/bpmn2.0">
<process id="helloWorld">
<startEvent id="start" />
<sequenceFlow id="flow1" sourceRef="start" targetRef="script" />
<scriptTask id="script" name="HelloWorld" scriptFormat="groovy">
<script>
System.out.println("Hello world")
</script>
</scriptTask>
<sequenceFlow id="flow2" sourceRef="script" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
</definitions>
Running the process
To run the process, we’ll be using the same main method as in the original article: bootstrap the engine, deploy the process and run it:
// Bootstrap
ProcessEngine processEngine = new DbProcessEngineBuilder()
.configureFromPropertiesResource("activiti.properties")
.buildProcessEngine();
ProcessService processService = processEngine.getProcessService();
// Deployment
processService.createDeployment()
.addClasspathResource("hello-world.bpmn20.xml")
.deploy();
// Run
processService.startProcessInstanceByKey("helloWorld");
The only thing that’s left to do, is add an activiti.properties file to src/main/resources that now points to a MySQL database. Alternatively, you could also use the cfg.create Ant target which is in the setup script of the Activiti distribution (see previous article).
database=mysql
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.1.102:3306/activiti
jdbc.username=activiti
jdbc.password=activiti
db.schema.strategy=create
Note that we’re setting the schema creation strategy to ‘create‘, since want to create the schema the first time we run our code. If you want to rerun your code afterwards, be sure to change it it ‘check-version‘.
Also, don’t forget to create the schema ‘activiti’ in MySQL and to add the user ‘activiti’ with enough permissions in MySQL.
Now just run it. The output should be non-surprising:

With that difference that we now actually are running on the MySQL database! See the proof on the following picture:

Download the source of this tutorial
The source for this tutorial can be downloaded as a ZIP file here. Just import it into Eclipse, point it your MySQL config and enjoy the ride!
Tutorial: a BPMN 2.0 Hello World With Activiti 5.0.alpha4 in 5 steps
With the 5.0.alpha4 release just out of the door, I thought it was time to demonstrate how easy it is to get started with the latest version of Activiti. Note That I’m not using the demo setup here, if you want that, check out my previous article.
In this tutorial, I’ll show you how we’ll run a very simple “Hello-World”-ish BPMN 2.0 business process on Activiti. From there on, you should be able to explore all the capabilities of Activiti, only limited by your imagination. In a later article, I’ll show you how to run this hello world app on MySQL.
Prerequisites
To follow this tutorial you’ll need
- Eclipse (or any other Java IDE)
- Ant
- 5 minutes of your time
Step 0: unzip the distribution
If you haven’t got it already, download the alpha4 release from the Activit website. Unzip this file.
Step 1: create a DB schema
Boot up an in-memory H2 database, that is shipped with the Activiti distribution:
cd activiti-5.0.alpha4/setup/
ant h2.install h2.start
You can now create the Activiti schema:
ant db.create
The result should look like this:

If you want, you can now inspect the database schema:
cd activiti-5.0.alpha4/apps/h2
java -cp h2*.jar org.h2.tools.Server -web
(I’m sorry for that last line, we’ll create an ant target to start up the web console in the next release)
Open your browser, and go to http://localhost:8082. Enter jdbc:h2:tcp://localhost/activiti in the field ‘JDBC URL’, leave all the rest as it is and click ‘connect’. You should see the Activiti schema in all its glory:

Step 2: Setup project
Open up Eclipse, and create a new Java project.
Add all the libraries from activiti-5.0.alpha4/lib/ to your classpath. You don’t need them all actually, but for speed we’ll just take the easy path here.
Step 3: Generate a configuration
The Activiti engine needs a small configuration file to run in a standalone way (ie not within a dependency container such as Spring for example). This config file can be generated from the terminal.
cd activiti-5.0.alpha4/setup
ant cfg.create
(The config file generator takes as input the build.properties and the build.${your_databae}.properties files. Tweaking these is content for a later blogpost!)
A config file and a jar with the same file is generated for you in the folder activiti-5.0.alpha4/setup/build/activiti-cfg and activiti-5.0.alpha4/setup/build/activiti-cfg.jar. Add this jar file to your project in Eclipse.
Step 4: Create the Hello World BPMN 2.0 process
The process we’ll model is very simple: a start and stop event, with a Hello-World step in between.

Granted, it can hardly be called a ‘business process’, but all things start small!
The XML representation of this process looks as follows. Add this XML file to your project and call it ‘hello_world.bpmn20.xml:
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
targetNamespace="http://www.activiti.org/bpmn2.0">
<process id="helloWorld">
<startEvent id="start" />
<sequenceFlow id="flow1" sourceRef="start" targetRef="script" />
<scriptTask id="script" name="HelloWorld" scriptFormat="groovy">
<script>
System.out.println("Hello world")
</script>
</scriptTask>
<sequenceFlow id="flow2" sourceRef="script" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
</definitions>
You can see here that our ‘hello world’ step is basically the execution of a Groovy script saying hello to the world. Note that the id of the process is ‘helloWorld’.
Step 5: run it
All that is left now, is actually running the process. Create a new class in your project and add a main method.
First, boot up the process engine:
ProcessEngine processEngine = new DbProcessEngineBuilder()
.configureFromPropertiesResource("activiti.properties")
.buildProcessEngine();
ProcessService processService = processEngine.getProcessService();
You can see that we’re constructing the process engine using our generated configuration file. The process engine gives access to different services (such as taskService, processService, etc.), as you can see on the last line.
To run the process, it first need to be ‘deployed’ to the engine. Deploying means that the process is parsed and stored in the Activiti database:
processService.createDeployment()
.addClasspathResource("hello-world.bpmn20.xml")
.deploy();
And now we can execute the process, using the id of the process as ‘key’:
processService.startProcessInstanceByKey("helloWorld");
Which gives as output the following:
Next stop: uber-BPM-powers
And that’s all thats needed to run your first BPMN 2.0 Hello World process!
Of course, this is only the start of a very interesting journey. Best place to get familiar with the capabilities of Activiti and BPMN 2.0, is to check out our userguide.
Stay tuned for articles that will build further on this example (eg. using Maven, MySQL and enhancing the process) !
Activiti 5.0.alpha4 released
A new month, a new release … the Activiti team keeps its pace!
Things are shaping up, and this will be the last release before we’re into beta.
Download the 5.0.alpha4 release here!
This release packs a bunch of goodies, which I’m sure will make you happy:
Improvements
- MySQL support
- Support for method expressions on sequence flow
- Revised ActivityExecution API
- Added ConcurrencyController API
- Process Event Bus
- Taskforms: added date and date picker support
- Explorer: changed process definition drop down list to a separate page
New features
- BPMN parallel gateway
- BPMN manual task
- BPMN (embedded) subprocess
- BPMN call activity (subprocess)
- BPMN Java service task
- Spring integration (experimental, no docs yet)
Bugfixes
- Made engine compatible with BPMN 2.0 beta process models
- Fixed exception on windows and linux when using boundary timer event
- Expression cannot have whitespaces
Screencast: Getting Started with Activiti 5.0.alpha2
I’m extremely happy to announce that Activiti 5.0.alpha2 just has been released!
Key feature of this release is the taskform functionality, many thanks to Erik Winlof for implementing them! Nothing could give it more credit than a screencast.

In this screencast, you”ll be able to enjoy:
- Setting up the Activiti environment using the demo setup script. As you’ll see, only 27 seconds are needed. That’s about the time it takes to pour a cup of coffee (if you’re fast).
- The Activiti Probe, REST, Modeler and Explorer webapps.
- The new taskform functionality. In the screencast, the vacation request BPMN 2.0 example is used. Check out our userguide to learn everything about taskforms and the example process.
Don’t forget to put on your speakers and to check the movie out in fullscreen!
JBug.be event tomorrow
Tomorrow, the JBoss User Group Belgium is organizing its third event. Since I’m co-founder of the user group, I’ll obviously hang around!
There is still room left last time I checked, so don’t hesitate to register (free) for the event here!
Great opportunity to network, learn and chat about what’s happening around us. Hope to see and chat with you there!!
Reactions to the Activiti launch
Monday morning, the world witnessed the birth of Activiti. And people saw that it was good. The stream of blogs, newsposts and tweets was unstoppable.
I tried to keep track of every item that appeared online, which was almost a fulltime job. But now the dust has settled (a bit), here is a list of interesting reactions to the Activiti launch.
Blogs
For a tech audience, blogs are the no. 1 news sources. Here’s a pick of what I’ve seen passing by in the blogosphere. Do let me know if I missed one!
- Tom’s blog, which triggered the start of the rollercoaster ride.
- Bernd Rucker from Camunda obviously had a post ready for the German market
- John Newton, CTO of Alfresco, explains in-depth the business reasons and opportunities behind the Activiti iniative.
- Sandy Kemsley, renowned BPM analyst, wrotea an objective analysis of the Activiti platform. She is eager to see how Activiti will evolve. And we won’t dissapoint her.
- BPM expert Scott Francis of BP3 wrote a very motivating blogpost. He actually downloaded the distribution and played with it. Let me quote him a few times here
- “Did I mention that the whole stack ran just fine, natively, on my Mac as well as a Windows VM?”
- “The documentation is already pretty comprehensive, and gets down to no-nonsense details (not true for many commercial products).”
- “I think the market is ripe for an open source BPM platform that leverages standard underlying technologies and is built from the beginning to allow for cloud-based deployment”
- “We may end up investing some time in the project ourselves.”
- The 451 Group posted a spot-on business analysis of the announcement, and let me quote them:
Activiti is likely to shake-up the BPM market with a ubiquitous project that supports the BPMN 2.0 standard from the Object Management Group.
- Peter Hilton from Lunatech Research, hits the nail on the head:
business processes and work-flow are aspects of most business software and integrating embeddable BPM will be a key element in reducing the cost of business software development.
- Theo Priestly asks the question everybody wanted to ask: “has the fight for open-source dominance begun?”
- Of course this was also great news for Alfresco users, as described on an Alfresco & Share blog.
- Infoworld focusses on the licence reasoning behind Activiti, and justly questions the value of GPL
- And Khaled Ben Driss, made sure that the French speaking countries had their share of the news:
- “Bravo pour cette initiative, à la sauce Apache, une licence business friendly …”
But the Activiti announcement wasn’t rainbows and puppies for a few, which led to the post from Active Endpoints. Thanks for the recognition guys! I was surprised to see that they see us as competitor
. I really like the picture (reminded me of one of my favourite cartoons):-) Anyway, I can’t put it more obvious then Sandy Kemsley did:
Activiti BPM : it’s neither fish nor fowl – stinging commentary on view that BPEL is dead, by a BPEL-based vendor
![]()
The heartbeat of the internet, Twitter, was (and is) buzzing of the announcement. At the time of writing, I counted around 250-300 tweets directly related to Activiti. I didn’t check for typos or querying on alfresco, personal names, etc, which would even up that number.
A small selection:
-
(vtri) Looking forward to see how Activiti kicks on within #Alfresco. Always felt jBPM wasn’t growing to its potential. Could be very exciting…
-
(stephan007) Tom Baeyens joins Alfresco and launches #Activiti http://bit.ly/aNAcM7 (via @tombaeyens) ;o)
-
(protocol7) Great to see @tombaeyens and @jbarrez working in the open again. And Activiti seems destined for ASF, even better #activiti
- (akuckartz) Tried activiti.org BPMN 2.0 implementation demo. First impression: it works!
- (SphericalN) bpm just got interesting with the launch of alfresco’s http://www.activiti.org/index.html – well as interesting as bpm can get
- (protocol7) But Activiti is pretty much jBPM so I would think many will move over
- (claudiabia) Very excited about the news of new BPM – #Activiti… Can’t wait to see it integrated with #Alfresco
- (rami22) Im so excited for #Alfresco #Activiti project can’t wait to download it tomorrow and play with it
- (david_syer) Pleased to see #activiti http://bit.ly/dwKbgp project announcements. Good stuff there for #spring users looking for workflow features.
- (andrkoel) Activiti: looks like the next version of jbpm with a better license and a better community
- (mjasay) Alfresco hires Red Hat’s jBPM team, partners w/ VMware’s SpringSource to deliver a cool Business Process Mgmt solution
- (sfrancisatx) wow. i step away from the computer for a few hours and the blog hits are nearing our daily record again. lots of interest in activiti #bpm
News sites
After the official Alfresco press release, many news sites picked it up quite quickly. Every google query I do seems to produce even more results, so in the end I stopped tracking them. For what it’s worth, here my list:
The H, Techworld, CNBC, BusinessWire, ZDnet, Forbes, ItWorld.com, CMSWire, BPMEnterprise, NetworkWorld, ReduxOnline, Boston BusinessNews, Heise.de, CMSReport.com, StreetInsider, Yahoo Finance, FierceContentManagement, EarthTimes, NewsBlaze, San Francisco City and Press, CentralDaily, SunHerald, iStockAnalyst, PR-inside, Sys-con, Dailyfinance.com, Ameritrade, EuroInvestor.co.uk, and many, many more (I have twenty or something more copied locally, but by now you’ll know the press release by heart
)
The curtains are pulled: Alfresco launches Activiti

After some weeks of silence, we can now finally pull the curtains … and reveal Activiti to the world!
Activiti is a super-fast and rock-solid BPM and workflow engine that natively runs BPMN 2.0. It’s completely open-source (Apache licence) and embeddable in any Java environment.
Tom and I joined Alfresco about two months ago, and we’ve kept ourselves quite busy. So together with this announcement, I’m proud to present the first alpha release of Activiti. Go and play with it while it’s hot!
Activiti is all about what made jBPM great, and taking giant leaps from there. Tom nicely summarizes it in his blogpost. A lot more information can be found on the Activiti website.
Official Alfresco press release: click here.
Regards,
Joram
Alive and Kicking!
You may have seen the Open letter to the jBPM community explaining that Tom and I step down from the jBPM project. We just want to let you know that we’re alive and kicking. We’re building a new BPM platform that’s architected for new IT requirements. It will be Apache licensed and it will run BPMN 2.0 natively. I can assure you …. exciting times are ahead!
That’s all we can share at this point. Stay tuned for more updates on ‘the what and the how’ very soon!
JBoss @ Fosdem 2010
This weekend, Brussels is again the place to be for every open-source enthousiastic. For the first time ever and with some help from the JBoss User Group Belgium, there is now a JBoss devroom where different JBoss talks will be given. The event is completely free, so no reason not to be there!
There will also be a jBPM talk, done by our friends at Camunda.
The complete program can be found here: http://www.fosdem.org/2010/schedule/devrooms/jboss
Hope to see you at the JBoss booth!
Book review: jBPM Developer Guide by Mauricio Salatino
I’ve managed to give the jBPM Developer Guide by Mauricio Salatino, which was sent to me less than a mont ago by the people of Packt, a thorough read. Reviewing a book is not a simple task, certainly not when the topic is quite familiar. So I started every chapter by writing down some notes of what I would expect to find, and checked while reading if the content could cover my expectations.
Since many people will simply skip to the conclusion part (at least, that’s what I do when I read a book review), I’ll start off with The Short Review.
The Short Review
Basically a book review needs to answer the following question:
Would you recommend the book?
Yes. I would certainly recommend the book to any novice jBPM user. The book covers practically all jBPM3 concepts and gently builds up the complexity of the content. Having this book a few years ago when I started out with jBPM, would have saved me tremendous time. Granted, the book has some minor flaws (see The Long Review), but it currently is the best guide and reference when you want to start using jBPM. period.
The Long Review
In the following sections, I will summarize for each chapters the notes I’ve taken while reading the book.
The book is published by “Packt Publishing”. The nice thing about Packt is that they are generally fast to publish books about new and exciting, mostly open source technologies. On top of that, they also invest a part of the profit back into the project, which is a noble deed if you ask me.
In general
- This book is about jBPM3, not jBPM4. One might think this is a bad thing, but do remember that jBPM3 is extremely stable and is part of the JBoss SOA-Platform for many years to come (today jBPM3 is the only official supported version by Red Hat – these things take quite a time). People that are familiar with jBPM3, will have no problems to make the jump to jBPM4.
- A general nuisance is the language usage throughout the book: although the sentences are syntactical correct, they often not feel ‘right’. Others have already commented on this fact, so I’m not going into it here. I don’t blame the author: he shows a great amount of enthusiasm and jBPM knowledge, but with a little more editorial reviewing, this book could have gotten that little extra edge.
- The book is great for jBPM starters, no single doubt about that. However, I would have liked to see more ‘best practices’ and advanced configurations (JMS/SOA/etc.). Let’s hope for a next jBPM book that covers those topics
Preface and Chapter 1: Why developers need BPM
This chapter is a bit overwhelming for beginners. The author tries very hard to convince people of the rightness of open source software (which is perfectly valid ), but it’s too heavy as a starter chapter. This chapter would have been a good appendix, I guess.
Oh yeah, I don’t necessarily agree with Mauricio’s definition of a ‘BPM suite’. You’ll understand it when you read it
Chapter 2: jBPM for Developers
Good introduction to some important concepts like wait states, nodes, process definition vs instance, etc. The downside of this chapter is that it tries to explain these concepts by building a simple state machine in Java code. In my opinion, 99% of the jBPM starters will find this too overwhelming. I found it fun to read, but then again my day job is to build such “state machines”
Luckily, it goes uphill from here. My advice would be to read the chapters 1/2 after starting from chapter 3, and only giving them a quick read either way.
Chapter 3: Setting up Our Tools
Mandatory chapter for every beginner. I really liked the fact that nothing is “taken for granted’, as tools like SVN and Maven are also covered with some text. Many technical books assume that this is common knowledge, but experience has taught me this certainly is not the case. I also really liked the ‘community’ take on things in this chapter. The author explains and demonstrates that by knowing maven, svn, etc. every one can contribute to open source ecosystem. As a core jBPM dev, I was happy to find these encouragements.
This chapter demonstrates in depth how tools (Maven, Eclipse, etc.) need to be configured to get the maximum out of your jBPM experience. Also the jBPM project structure is touched, which is in reality a true knowledge advantage I’ve not yet seen in many jBPM users.
A small side remark (has no influence on jBPM novices, ofc.): the history of jBPM is a bit skewed, which is a bit of a pity if you’re closely involved with the project (eg. jBPM was orginally not created by JBoss)
Chapter 4: jPDL language
When I was reading this chapter, I noted down “To the point! This is the content you need”! I can’t express it better than that. A must-read chapter for every jBPM adept.
I was delighted too see that the author often explains functionality by referring to snippets in the source code. In my opinion, this is the way open source tech books should be. When I was still a jBPM consultant, I often looked at the source code to learn how corner cases where handled, or what exactly a certain operation does, etc. As Ronald often states on the jBPM User Forum: the best documentation is the source.
Chapter 5: Getting Hands Dirty with jPDL
In this chapter, the topics explained in the previous sections are used in a real project. The use case is interesting and has great didactical value. I had some reservations when I read the use case, and noted down some questions on how the author would tackle them (if they were tackled at all). I was happy to find them all answered by the end of the chapter. Perhaps a small remark could be here that the jBPM configuration isn’t showed in this chapter. This could be a bit confusing for some starters, since it involves some “magic” that is easy to explain.
Chapter 6: Peristence
Really thorough and detailed explanation of jBPM persistence. Excellent transaction explanation and great diagrams that explains what happens in which situation (automatic nodes, wait states, when updates happen, etc.). Really every aspect is covered (for example even Hibernate caching is touched), nice!
Imo, perphaps the best chapter of the book.
Chapter 7: Human Tasks
Perfect follow-up for the previous chapter. Good, detailed content about probably the most important construct of any BPM engine. I also really like the webapp approach at the end of the chapter: this is the stuff why people buy the book.
Chapter 8: Persistence and Human Tasks in the Real World
This chapter perfectly aligns with the previous Human Task sections: good and very detailed content.
Chapter 9: Handling information
Great explanation about variable usage in jBPM. The content is good for starters and should get you going quite far. But in my opinion, some things should have gotten more attention, since variables are an area in which many mistakes are made in real life projects. Some topics that could have gotten more love: hibernate objects as variable (+ why !), serializable (what about synchronisation problems?), business keys for process instances (why do you need them).
Chapter 10: Advanced features
This chapter definitely covers some advanced features. It even managed to surprise me: I had totally forgotten about the superstate indirections using “../” in the node names (altough I’ve used it a lot on a certain project) and the book mentioned this little detail! Also start tasks were covered – nice!
Some topics which I have needed a lot in my past projects weren’t covered (but this is really advanced stuff, and definitely not for startes): subprocess binding, more database schema focus, e-mail node and custom HQL queries using the jBPM objects. So altough I really liked the chapter, it could have gotten extra points when dealing with those topics.
Chapter 11: Advanced topics in practice
Not to miss chapter since here asynchronous execution is explained. The books goes really deep in the nitty gritty details of async executions – which I like. However in my opinion, the book doesn’t stress enough the crucial importance of the async functionality enough. But after reading this chapter, you’ll definitely be able to understand and try it for yourself.
Chapter 12: Going Enterprise
Explanation of what the jbpm-enterprise jar offers. Some good practices are states here, like the EJB intermediate layer with ids (jBPM4, anyone?). Also remote client usage is covered, together with Timers and job (VERY good explanation btw).
As my conclusion already can be found in the beginning of this post, I’ll repeat here the one-sentence summary. If you are starting out with jBPM, there is no better book or guide to get you guys. Highly recommended!

