Compilation error with "Unhandled exception type Exception" message occurs only in executable model.

Solution Unverified - Updated -

Issue

When I build a rule containing a method call which might throw an Exception like (*2-1) in constraint (*1-1), compilation error (*3) occurs only in executable model.

(*1) Example rule

import static com.example.reproducer.Fact.checkedValue

dialect "mvel"

rule "Rule 1a"
    when
        $fact : Fact( $value : checkedValue(1) )    // <-- (*1-1) Use a java method which might throw an Exception in constraint
    then
        modify($fact) {
            value = $value
        }
end

(*2) Example Fact class:

public class Fact {

    private int value;

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public static int checkedValue(int value) throws Exception {    // <---------- (*2-1) Declare "throws Exception"
        if (value < 0) {
            throw new Exception("Error occurred");
        } else {
            return value;
        }
    }
}

(*3) Error with "Unhandled exception type Exception" message

[ERROR] Failed to execute goal org.kie:kie-maven-plugin:7.67.0.Final-redhat-00017:generateModel (default-generateModel) on project reproducer_throwable_method_in_constraint_1b: Execution default-generateModel of goal org.kie:kie-maven-plugin:7.67.0.Final-redhat-00017:generateModel failed: [com/example/reproducer/PA9/LambdaExtractorA915DA9C2DA393CFEF4F6BD2275C8478.java (20:727) : Unhandled exception type Exception] -> [Help 1]

Environment

  • Red Hat Decision Manager (RHDM)
    • 7.12.0 - 7.13.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content