Tuesday, April 20, 2010

jBPM v3.2 custom exception framework example now available

In December of last year I posted on a project of mine called a custom exception framework. I have been working on this for the last few months and have now put together a running unit testing example to demonstrate the final results and committed this to the jBPM projects directory.

The idea is that you are now able to use a single exception handling process (see image provided) to provide all your processes with exception processing. There are only two options in this framework, a human task to allow fixing your processes problems by hand or a retry option to allow for automated continuation based on settings you define.

Currently the unit test demonstrates only human task fixing of a single node failure, but I will continue to work on this. I plan to complete a state node failure and demonstrate the Retry option.

The project includes maven dependency handling (see the pom.xml) and you can start in the readme.txt file included at the root level of the project.


  1. Hi, Eric.

    could you please explain me what is the difference between Exception Handling for process based on BPMN and Exception Handling based on JBPM. Thanks!



  2. Michael,

    Just because a process is defined in a language (BPMN or jPDL or whatever) does not mean that the underlying engine provides for error handling.

    jBPM is a process engine implementation done in Java, which provides a single Exception exit from your code. It leave how to handle that Exception to you and your developers.

    This article points to a solution that allows you to keep process errors in the process and decide what you can/might/will do with them.

    In this example you can Retry the process step that failed or you can create a Human Task to look at the problem before deciding what you want to do with the error. It is a very simple educational starting point for someone wanting to make their business processes more robust and flexible.

    I hope this clarifies it a bit?

  3. This projects code has been placed into github too, as the svn of jbpm3 has been removed from the project site (links gone), I don't want to lose it:


  4. Hi Eric,

    I am planning to implement something similar to yours, but the different is I want to define a global exception handler for the whole process and rout the exception to a exception handler node.
    This involves changing the normal flow of a process.
    Can you please tell me if this is a good solution?
    This is the code for it:

    public class ExceptionHandler implements ActionHandler {

    public void execute(ExecutionContext context) throws Exception {
    Node endNode = context.getProcessDefinition().getNode("Exception Node");

    if(context.getToken().getNode() != null){
    List existingTransitionList = context.getToken().getNode().getLeavingTransitionsList();
    for (Transition existingTransition : existingTransitionList){
    } else if (context.getTransition() != null){


    1. This framework does this for you, you just catch your exception in the node in your flow where it happens, then persist the flow at that point, step out to the exception framework, process the error and either go back or not as you determine in the exception framework.

      You will want to do your modifications in the error handling nodes that I have put as demo nodes. You can add, remove or create new ones in the framework as your project requires.

      You can cleanup the flow you exited if you don't return for a retry.

      Check the project code, it does something like what you do here.