1 Reply Latest reply on Jul 17, 2007 1:48 AM by Kevin Wilson

    process-state exception handling

    Kevin Wilson Newbie

      I am trying to write a exception handler for a process state node. The sub processes may throw a variety of exceptions. These exceptions need to be caught when the subprocess is wrapped by another higherlevel process. The higherlevel process we have the process-state node defined as:

      <process-state name="Process Target">
       <sub-process name="subProcess"></sub-process>
       <transition name="" to="updateStatus"></transition>
       <exception-handler>
       <action class="....StatusDetailExceptionHandler"></action>
       </exception-handler>
       </process-state>



      However, when we try to test this in the debugger, the exception is first caught by the Node calling the action. It then tries to raise the exception, and ends up delegating to the subprocess definition, which throws a DelegatedException().
      Since the ProcessState.enter() does not wrap with a Catch, the exception is never processed by this node this the exception goes up the stack to the previous Node, and its exception handler does get called.

      Potentially handling the exception in the incorrect way.

      The work around I came up with is to define a node previous to the process state to define the exception handling for process state. And a exception transistion taken by the handler.

      <node name="handleException">
       <transition name="" to="subProcess"></transition>
       <transition name="exception" to="updateStatus"></transition>
       <exception-handler>
       <action class="....StatusDetailExceptionHandler"></action>
       </exception-handler>
       </node>
       <process-state name="Process Target">
       <sub-process name="subProcess"></sub-process>
       <transition name="" to="updateStatus"></transition>
       <exception-handler>
       <action class="....StatusDetailExceptionHandler"></action>
       </exception-handler>
       </process-state>



      Is there any better workaround?

      Kevin

        • 1. Re: process-state exception handling
          Kevin Wilson Newbie

          Have a additional problem when attempting to call ctx.leaveNode() from the ExceptionHandler in the process above. The ctx.getSubProcessInstance() returns null, then throws followon exception.

          Caused by: java.lang.NullPointerException
           at org.jbpm.graph.node.ProcessState.leave(ProcessState.java:197)
           at org.jbpm.graph.def.Node.leave(Node.java:357)
           at org.jbpm.graph.exe.ExecutionContext.leaveNode(ExecutionContext.java:120)
           at com.hp.ovcm.ope.nodes.StatusDetailExceptionHandler.executeImpl(StatusDetailExceptionHandler.java:23)
           at com.hp.ovcm.ope.nodes.Node.execute(Node.java:27)
           at org.jbpm.graph.def.Action.execute(Action.java:122)
           at org.jbpm.graph.def.ExceptionHandler.handleException(ExceptionHandler.java:60)