3 Replies Latest reply on Apr 22, 2008 11:22 AM by syedtaj

    jBPM Exception Hanlding, how to pass the exception object

    syedtaj

      Hello,

      I am trying to write exception handlers for a process definition.

      When an exception occurs, I would like the ExceptionHandler to be executed. However it would be crucial for me to know what exception message was in CommonHandlerException.

      The sample code

      <exception-handler
      exception-class="com.grow.automation.client.tn3.handlers.CommonHandlerException">
      <action name="Handle any exceptions that occur in the nodes"
      class="com.grow.automation.client.tn3.handlers.ExceptionHandler">
      </action>
      </exception-handler>


      Thus when a CommonHandlerException is thrown, ExceptionHandler will be executed as action, but how do I make sure that the exception object is passed on to the action class.

      Kindly advice.

        • 1. Re: jBPM Exception Hanlding, how to pass the exception objec
          syedtaj

          Sorry the code did not come correctly

          Here goes -


          <exception-handler
          exception-class="com.grow.automation.client.tn3.handlers.CommonHandlerException">
          <!-- <acton name="Handle any exceptions that occur in the nodes"
          class="com.grow.automation.client.tn3.handlers.ExceptionHandler">
          </acton> -->
          </exception-handler>




          • 2. Re: jBPM Exception Hanlding, how to pass the exception objec
            syedtaj

            Pardon again, the code just doesnt come in quotes.

            Let me repeat the question -

            Here goes -

            I am trying to write exception handlers for a process definition.

            When an exception occurs, I would like the ExceptionHandler to be executed. However it would be crucial for me to know what exception message was in CommonHandlerException.

            <exception-handler
            exception-class="com.grow.automation.client.tn3.handlers.CommonHandlerException">
            action name="Handle any exceptions that occur in the nodes"
            class="com.grow.automation.client.tn3.handlers.ExceptionHandler">
            /action
            </exception-handler>



            Thus when a CommonHandlerException is thrown, ExceptionHandler will be executed as action, but how do I make sure that the exception object is passed on to the action class.

            • 3. Re: jBPM Exception Hanlding, how to pass the exception objec
              syedtaj

              Hi,

              Can anyone guide me on this please.

              When we get an exception during the jBPM process, an exception handler is invoked. But this exception handler is not aware of the exception that occurred.

              I need to capture the error message and the stacktrace.

              I am sure everyone will face this problem. Currently I am setting the exception object as a process variable. However to do that, I am forced to put a try catch block in all the action classes and catch Exception like the following (so that all runtime exceptions are also captured)

              public class SampleActionHandler implements ActionHandler {
              
               public void execute(ExecutionContext executionContext) {
               try {
               ................
              
               } catch (Exception e) {
               executionContext.setVariable("Exception", e);
               }
               }
              }
              


              This method is terrible, Does anyone have a better idea?