Task 1: Using automatic exception handling

You import and run the faulty decision service. You find an exception error in a rule, and try to fix the problem by using automatic exception handling.

About this task

Before you make any changes to the faulty decision service, you want to see the results that it produces. You import the decision service into Rule Designer, and then run it. The results show a null pointer exception in a rule condition. Before going further, you activate the automatic exception handling feature to see whether it can correct the exception.

Step 1: Running the decision service

You import the start projects for the tutorial, and run the decision service.

Before you begin

If you have imported the answer projects to run the completed decision service, close or delete them before importing the start projects into the same Eclipse workspace. Otherwise, use the start projects in a different Eclipse workspace.

Procedure

  1. Open the Samples Console in the en_US (American English) locale (see Running samples from the Samples Console).
  2. In the Samples and Tutorials view, expand Rule Designer > Tutorials > Debugging a decision service.
  3. Under start, click Import projects.

    Eclipse switches from the Samples Console to the Rule perspective. The Rule Explorer displays six projects:

    Image shows the rule projects.

    The Java™ project loan-validation-xom defines an execution object model (XOM) for the rules. The main decision service, Loan Validation Service, references the other projects. The decision service is described in the tutorial "Creating a decision service with multiple projects" (see Running the completed tutorial).

  4. From the Run menu, select Run Configurations.
  5. Expand Decision Operation, select the run loan validation configuration, and click Run.
    The Console view shows the results, which include an exception error.

Step 2: Applying automatic exception handling

Because the exception occurs in a rule condition, you decide to try to fix it by using automatic exception handling (see Automatic exception handling).

Procedure

  1. In the Rule Explorer, right-click Loan Validation Service.
  2. In the pop-up menu, click Properties, and select Rule Engine in the left column of the Properties dialog.
  3. Select Automatic exception handling in conditions, and then click Apply and Close:
    Image shows automatic exception handling in conditions.
  4. Run the run configuration that is shown in step 1 of this task.
    The results no longer show an exception error. The decision engine automatically handles the exception. To determine where the exception takes place, you add more logging information to the results.

Step 3: Adding exception handing logging

You add additional logging information to determine where the decision engine automatically handles the exception error. First, you look at the Loan Validation Service/logging.properties file, and set it as the logging configuration file. Then, you set the Java VM parameter of the run configuration to declare the path to the logging configuration file.

Procedure

  1. In the Rule Explorer, double-click Loan Validation Service/logging.properties.
    The file sets the Console as a logging handler:

    handlers = java.util.logging.ConsoleHandler

    It also sets the log level for the automatic exception handling to FINE.

  2. Open Run > Run Configurations, and select the run loan validation configuration.
  3. Open the Parameters and Arguments tab, and add the following VM argument:
    -Djava.util.logging.config.file="${workspace_loc}/Loan Validation Service/logging.properties"
  4. Click Apply, and then click Run.

    The Console shows the results, which include a log message for the automatic exception handling. The results tell you that the exception takes place in a condition in the checkZipcode rule.

What to do next

In the next task, you add breakpoints to a ruleflow to determine where the exception handling occurs.