Top
Systemwalker Runbook Automation Studio User's Guide
Systemwalker

11.1.7 Dealing With Errors in Java Actions

When an error occurs during the execution of a Java Action, an exception is thrown. Systemwalker Runbook Automation allows you to define your own error handling for erroneous Java Actions. In this way, you can prevent that a process instance goes into error state when an exception is thrown.

In addition, you can define actions for Java Actions which perform a "cleanup" before a transaction is rolled back and a process instance is set to the error state. This includes a rollback of all Java Actions in a Java Action Set, and allows you to perform general actions (e.g. sending notification emails in any error case), or executing some specific actions before setting the process instance to error state.

Systemwalker Runbook Automation provides the following options to handle errors in Java Actions:

To define Error and Compensation Actions for regular Java Actions:

  1. Click the empty space in the Process Definition editor or select the node to display the Properties view for the process definition or the node respectively.

  2. Select the Action Set tab.

    The Properties view displays all Java Actions that are available for the selected process definition or node. If you have not yet defined any Error or Compensation Java Actions for a regular Java Action, empty folders for Error and Compensation Java Actions are shown. The following figure shows a Prologue Actions folder for an Activity Node, consisting of two Java Actions:

    Figure 11.5 Properties view with Prologue Actions

  3. Select the regular Java Action for which you want to define an Error and/or Compensation Action.

  4. Select the Error Actions or Compensation Actions folder or any Error or Compensation Action inside the folder, and click Add.

    The Action Type List dialog is opened where you can select a Java Action and add this action as a new Error or Compensation Action.

  5. In the Action Type List dialog, expand the folder where the Java Action to be added is located. Select the Java Action, and click Create.

    A dialog is displayed where you fill in the details for the selected Java Action. Perform operations required depending the action you selected.

  6. When defining an Error Action for a Java Action: In the Action Editor for the selected Java Action, click the Error Handling tab. Here you can specify the following error handling settings:

    Note

    This tab is only available when defining Error Actions on process definition level or a regular Java Action. On process definition level and when defining Compensation Actions, this tab is not available.

    Figure 11.6 Displaying the Error Handling Tab

    • Behavior after Error: Specifies the behavior of the process instance after executing the Error Action. Select the Goto Error State radio button if you want your process instance to go to error state. In case of an error, the Compensation Actions specified for the Java Actions and the Error Actions on process level are executed, the process instance is rolled back, and the instance is put to error state.

      Select the Continue after Error radio button to continue executing your process instance. In case of an error, the exception gets caught, the Error Actions specified for the failed Java Action are executed, and the process instance continues. The default setting is Goto Error State.

      Note

      If you have defined several Error Actions with different settings, the Goto Error State setting overrides the Continue after Error setting.

    • Exceptions to React to: You can choose which kind of exceptions trigger the execution of the Error Action. If you want the Error Action to react on any kind of exception, select the Catch All Exceptions radio button. In that case, the Add and Remove buttons are disabled.

      Select the Catch Specific Exceptions radio button if you want the Error Action to react on specific exceptions. In that case, you have to specify the exception class names (for example, java.lang.NullPointerException), using the Add and Remove buttons.

      Note that if you specify java.lang.Exception as exception class, the behavior will be the same as when specifying Catch All Exceptions, because all exceptions belong to this class unless you are more specific.

    You can combine all error handling settings. Each combination results in a different error handling procedure. The following table shows all possible combinations and their impact on executing the defined Java Actions:

    Error Handling Settings

    Goto Error State

    Continue after Error

    Catch All Exceptions

    If a Java Action throws any kind of exception, the specified Error Action is executed. The transaction is rolled back, and the process instance goes to error state.

    If a Java Action throws any kind of exception, the specified Error Action catches this exception, and the process instance continues.

    Catch Specific Exceptions

    If a Java Action throws the specified exception, the Error Action is executed. The transaction is rolled back, and the process instance goes to error state.

    If a Java Action throws an exception that is not specified, the Error Action is not executed, the transaction is rolled back, and the process instance goes to error state (default error handling behavior).

    If a Java Action throws the specified exception, the Error Action catches this exception, and the process instance continues.

    If a Java Action throws an exception that is not specified, the Error Action is not executed, the transaction is rolled back, and the process instance goes to error state (default error handling behavior).

  7. Fill in details for the selected Java Action, specify the Error Action behavior, and click OK.

    The new Java Action is displayed in the Properties view. In the example, one Error Action and one Compensation Action have been added to the Prologue Action.

    Figure 11.7 Adding Error and Compensation Actions