Friday, July 29, 2011

jBPM5 on AS7: Lightning !

Most of you probably know that JBoss Application Server 7 has recently been released in the community. Due to its lightweight and modular approach, concurrency and much more, the startup time has descreased significantly, which is always nice to hear for developers! Although I still have to figure out how to get a cup of coffee in only 3 seconds now ;)

During my holiday break, I took some time to play with it, and see how difficult it would be to get jBPM5 running on AS7. It took me some time, but in the end I managed to get the jBPM console running on AS7. I'll describe the steps I took to get there now, but we'll try to get this integrated in the installer in the near future, so other people can start playing with this stuff more easily as well (any volunteers?).

I started with downloading JBossAS 7.0.0.Final and took the jBPM 5.1.0.Final jbpm console wars as a starting point.

  • Biggest change probably is the fact that as7 ships with JPA2 and hibernate4, while jBPM is still using JPA1 and hibernate3. Due to it's modular design, we can however still run hibernate3 applications on as7, we just need to add these dependencies ourselves now (and exclude hibernate4).

    • Add the following jars from the jBPM runtime to the WEB-INF/lib folder of the server war: hibernate-core, hibernate-entitymanager, hibernate-commons-annotations, hibernate-annotations, dom4j, javassist

    • Make sure to exclude the hibernate4 jars, by adding the following WEB-INF/jboss-deployment-structure.xml in the server war:
      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
      <deployment>
      <exclusions>
      <module name="org.hibernate"/>
      </exclusions>
      <deployment>
      </jboss-deployment-structure>

    • I got an error with my persistence.xml and JPA2 so I disabled JPA2 scanning by commenting out the JPA module (org.jboss.as.jpa) and subsystem (urn:jboss:domain:jpa:1.0) in the standalone.xml configuration file.

  • Data sources are no longer specified by dropping a *ds.xml in the deploy folder but as part of the configuration. In configuration/standalone.xml, add the following datasource:
    <datasource enabled="true" context="true" name="java:jboss/datasources/jbpmDS">
    <connection-url>jdbc:h2:tcp://localhost/~/test</connection-url>
    <driver>h2</driver>
    <pool></pool>
    <security>
    <user-name>sa</user-name>
    <password></password>
    </security>
    <validation></validation>
    <timeout></timeout>
    <statement></statement>
    </datasource>
    Notice that we also changed the jndi name of the datasource as we need to use one of the known domains (jboss in this case). This means you also need to change the name of the datasource in your persistence.xml.

  • The security configuration is also different, you should now add a security domain in the standalone.xml and copy the users.properties and roles.properties file in the WEB-INF/classes folder:
    <security-domain name="jbpm-console" cache-type="default">
    <authentication>
    <login-module code="UsersRoles" flag="required"/>
    </authentication>
    </security-domain>

  • Add your database driver (in our case h2.jar) to WEB-INF/lib of the server war.

  • The default transaction manager lookup no longer works (as its jndi name has changed) so I registered a custom transaction manager lookup
    • In persistence.xml, add
      <property name="hibernate.transaction.manager_lookup_class"
      value="org.jbpm.JBPMTransactionManager" />

    • Create the JBPMTransactionManager class and add it to the WEB-INF/classes or lib folder
      package org.jbpm;
      import java.util.Properties;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import javax.transaction.Transaction;
      import javax.transaction.TransactionManager;
      import org.hibernate.HibernateException;
      import org.hibernate.transaction.TransactionManagerLookup;

      public class JBPMTransactionManager implements TransactionManagerLookup {
      public Object getTransactionIdentifier(Transaction transaction) {
      return transaction;
      }
      public TransactionManager getTransactionManager(Properties properties) throws HibernateException {
      try {
      return (TransactionManager) new InitialContext()
      .lookup("java:jboss/TransactionManager");
      } catch (NamingException e) {
      throw new RuntimeException(e);
      }
      }
      public String getUserTransactionName() {
      return null;
      }
      }

  • There is another persistence.xml file in the jbpm-human-task jar (which is also bundled in the server war) which actually shouldn't be there, and is picked up by as7 at deploy time, so you should just delete that persistence.xml file (as for example discussed in this blog).

  • Finally, there was a problem in the FormProcessingFacade of the bpm console code. It was no longer picking up correctly when a form was sending data as plain/text, as there were now new properties in the media type related to encoding that made the equals fail. So I had to change line 228 in FormProcessingFacade to this (checking only for plain/text mediatype and simply ingoring properties:
    if("text".equals(mediaType.getType()) && "plain".equals(mediaType.getSubtype()))

Ok, this might sound a little scary, but don't worry, you won't have to do all this manually yourself, once we update the build to generate as7-compatible wars and update install script, it should be able to handle most of this! I just wanted to share this with anyone who might be trying to do something similar.

Still need to check how to deploy the BIRT reporting engine on as7 and then the jbpm-console is fully functional. Tihomir has already looked at deploying the designer on as7 and generated a customized war in the build for that.

Tuesday, July 5, 2011

jbpm-examples (part 2)

One example that is part of the jbpm-examples module is the request example, an advanced example that shows you how you could use a BPMN2 process to handle incoming requests. The process uses some of the more advanced features to model flexibility in your process in combination with business rules to specify part of the business logic.



The example itself is available in the jbpm-examples module so you can download and try it out yourself, but here are two small screencasts that show it in action. It uses a very simple demo client (that was created for this demo to make it easier to show some of the features). Some of these features are:
  • request validation using a business rule task
  • ad-hoc sub-process where the user can select process fragments to execute
  • dynamically adding a new sub-process to an ad-hoc sub-process
  • dynamically adding a business rule to automate fragment triggering
  • complex event processing to monitor the process engine
The demo can be found here:
request demo part 1
request demo part 2

jbpm-examples (part 1)

As already mentioned in the jBPM 5.1 release notes, there is now a new jbpm-examples module that contains a set of sample BPMN2 processes that show how to model and use some of the features, like how to do looping and multi-instances, human task management and task forms, etc.

You can simply import the jbpm-examples folder in Eclipse to take a look at the processes and test and debug them using the associated Java main classes or junit tests.

The largest set of processes is probably the BPMN2 junit tests. For most of the BPMN2 constructs that are currently supported, there are probably one or a few tests that show how it works. On top of that, there are a few larger examples that show some more advanced features, like:
  • looping
  • multi-instances
  • human tasks (including user / group assignment, delegation, forms, etc.)
  • process + rules integration (see part 2)




The jbpm-examples can be found as one of the artefacts in the download section. There is a separate chapter on these examples in the documenation. And the sources can be found here.

Enjoy and learn!

Thursday, June 30, 2011

SwitchYard integration is coming

For those who might not be familiar,
SwitchYard is a lightweight service delivery framework providing full lifecycle support for developing, deploying, and managing service-oriented applications.

You mean like an Enterprise Service Bus (ESB)? Yeah, kind of. At it's core, SwitchYard provides an embeddable services runtime with limited dependencies, allowing you to deploy and run services where you need them. The main difference between SwitchYard and traditional ESB offerings is that we are trying to make the runtime a transparent detail in the service lifecycle. SwitchYard aims to keep you focused on your services by providing tooling to help define, test, and manage the important details of a service - it's contract, policies, configuration, composition, and management . After all, the least important detail of your service is where it runs.
Good news, as this next-generation ESB will already offer jBPM integration in its 0.2 release, where SwitchYard services can easily be invoked from inside a jBPM process, as a domain-specific service.

For more information, check out the Wiki document and the associated example about the SwitchYard BPM component.

Thursday, June 23, 2011

jBPM 5.1.0 released!

We're proud to announce the release of jBPM 5.1.0.
jBPM is a flexible open-source Business Process Management (BPM) Suite. The core of jBPM is a light-weight, extensible workflow engine written in pure Java that allows you to execute business processes using the latest BPMN 2.0 specification. It can run in any Java environment, embedded in your application or as a service. On top of that, it supports a lot of tooling to support the business process through its entire life cycle, both for developers and business users. This includes an Eclipse plugin, web-based Designer, repository, management console, etc.
You can download everything here.

jBPM 5.1 includes a lot of small bug fixes and feature enhancements based on the feedback we received from the community (for jBPM 5.0). Most important improvements include:
  • The web-based Designer has been extended significantly to support all BPMN 2.0 constructs and to allow full round-tripping between the Eclipse-based and the web-based editor. It also supports domain-specific nodes now, can be embedded, etc.

  • A new jbpm-examples module contains a large number of example processes to show features like human tasks (including data passing and task forms), looping, multiple instances, rule-based integration, etc. I will describe some of these examples in more detail in some additional blog entries in the next few days.

  • Improved testing and debugging capabilities so you can easily JUnit-test your processes.

  • The documentation has been refactored, updated and extended. There's a new Overview and Getting Started chapter, and much more. And we'll continue this work in the next few weeks as well, so you can expect more details soon.

  • The new BPMN 2.0 Eclipse plugin has made significant steps forward as well. The goal of this new editor is to support the full BPMN 2.0 specification . It's still work in progress but it can already be used to create executable BPMN2 processes and execute them on jBPM5. We'll be working hard to improve the usability in the next few months.

  • Smaller feature enhancements, like
    • Automatic synchronization of processes in the jbpm-console when new proceses are deployed on the Guvnor repository
    • Simplified data passing to and from human tasks (and forms)
    • Extended BPMN2 engine with support for repeating timers
    • Support for multi-threading
A full overview of everything that was included can be found in the jBPM JIRA.



jBPM 5.1.0 is synchronized with Drools 5.2.0, which also has just been released. If you want to know more, take a look here.

I'd like to thank everyone that contributed to this release! This includes not just the core developers obviously, but everyone in the community that contributed in one way or another, from testing, improving documentation, creating examples, bug reporting to submitting patches and feature contributions!

Tuesday, June 21, 2011

JBoss OneDayEvent Munich, October 13th

I'll be speaking about jBPM5 at the JBoss OneDayEvent in Munich on October 13th, 2011.
As the successor of the successful JBoss OneDayTalk 2010 conference, the JBoss User Group Munich e.V. will organize a full day JBoss conference in Munich again. On 13.10.2011, everything will once again revolve around JBoss technologies and Java frameworks, with the focus on current topics such as Enterprise in the Cloud, Security, Operations, High Availability, Scalability, ESB, Web 2.0, Mobile, Clustering, and BPM / BPEL / BRM content.
There will be a lot of interesting presentations about a ton of different JBoss technologies, given by core developers themselves. So this is the ideal opportunity to get all these technical details you're looking for and asking those hard questions! Or just to meet and greet the people behind the projects.

For a full agenda and more details:
http://onedaytalk.org/

Hope to see you there! And if you're quick, you can still take advantage of the early bird discount.

Wednesday, June 15, 2011

Argentine Workshop Update

An update on the Argentina June Workshop!

Most of the core developers of the jBPM and Drools team have been trying desperately to get to Buenos Aires. But the volcano in Chile has made that very difficult.

I'm back home, never got any further than Madrid, so they put me on a flight back home instead after two days of hotel and no immediate opportunity to still go the Buenos Aires. I'll do my jBPM5 presentation remotely and will try to be available as much as possible (man, this is Eyjafjallajokull all over again).

But it seems like the volcano issues are dying out. As a result of all this delay though, the Thursday workshop day will unfortunately have to be cancelled. But Friday is confirmed, so the workshop will take place! We'll just have to rearrange the content a little into one day again. And this will give everyone the opportunity to reach Buenos Aires in time as well.

But you can't argue with nature! So enjoy the trip and the workshop, from what I've heard it's worth it ;)