Friday, April 11, 2008

jboss, seam, jbpm

I’ve been working in the jboss/seam framework for a few months now and recently tried to add jbpm workflow functionality to a project. In attempting to do this, I’ve hit some rough patches that have caused me to place the jbpm parts of the project on hold as they were not “mission critical” to this prototype.

Note that these remarks are in the context of a seam 2.0/jboss 4.2x environment (jboss 4.2+ is required by seam 2+), running on OSX 10.5. The jboss/seam/jbpm combination appears to be the source of the problems, OSX 10.5 appears irrelevant.

Seam offers two ways to utilize jbpm in your applications: the first is pageflow; the second is what the documentation terms an overarching business process.

The seam pageflow model is, as one would expect, a way to map desired page to page transitions using an xml file. It is described as being similar to other pageflow definition languages such as spring web flow but built with a conversation model in mind. The idea is that conversations allow better support for random user navigation e.g., hitting the back button. I cannot comment on that claim, but having used pageflows a bit I’ve found them adequately expressive and useful.

The difficulties that I have had are centered around integrating an overarching business process into my seam application. These business processes may include asynchronous server and user processes executing over long periods of time, e.g., weeks. A simple example is the verification of user identity in a web facing system: A user requests an account on the system, and activates the account by responding to an email sent by the system.

The business process requires the system to send an email to the user following the initial request, validate the response or, in the absence of a response, retire the request/send another reminder

The first issue I had in incorporating this workflow is the classic “who’s on top” problem, since I found that pageflows could not initiate workflows.

My prototyping started with a pageflow, as pageflows are the natural frameworks for handling the request for a new user account. The pageflow structure makes it easy to verify that the requested username/password etc satisfy system requirements. If they don’t, the application can be configured to just sit on the request page and not proceed to subsequent pages.

For example, by enclosing the page redirect in a <> construct, the return of a null from the userHome.persist method keeps the application on the page (there is a protocol (not shown) that allows the application to post error messages on the page).

<navigation from-action=?#{userHome.persist}?>
<redirect view-id=?/User.xhtml?/>

However, as mentioned above, a pageflow cannot initiate a workflow, so it is necessary to enclose the pageflow within a workflow to achieve the desired result. This entails changing the preceding page so that it kicks off a jbpm workflow rather than simply going to the next page.

This is the point at which I realized that I would need tools for monitoring and debugging workflows. The jbpm console appears key to this. Disconcertingly, I could not get the console to run with jboss 4.2.2.GA. This appears to be a general problem. In my case, the instructions on the wiki enabled me to get my workflow initiated without it throwing exceptions but I still was unable to get the console working.

One suggested path was to build the console from source. However, I proved to be unable to get it to build from source with the level of effort I was willing to expend. After reading posts such as this, I concluded that building from source may not be the most productive experience.

The bottom line is that you’re in an odd space working with seam 2.0 -- it needs jboss 4.2X but some of the other redhat/jboss tools don’t yet support jboss 4.2. I’m a bit surprised that this is the case: seam 2.0 GA was released 2007-11-01 06:49 and jboss 4.2.2 was released 2007-05-11.

Since I expect this situation to eventually be rectified, and as I mentioned, workflow was not “mission critical” I decided to wait for a working console application to be posted on the site.

In fairness I’m working from the community “minimally supported” version -- the situation could be radically different in the supported versions.


Ronald said...

Some comments from an 'insider'

jBPM does run on JBoss AS 4.2.2. But it's true the downloadble 'binary' does not since it is targeted at 4.0.x. The reason for this is some backported JSF 1.2 classes and JSF itself.

The suggestion to work form the source is a correct one. It currently should build, just do not use cvs-head but the 3.2 branch.

sohbet15 said...

Thank you very much for this useful article and the comments.

Andrei said...

You can check a product called E7 by Exadel:

It addresses exactly the problem of using jbpm with seam, mixing services and pages, maps seam context to services input/output.

rdf said...

Thanks, I'll give it a shot.