RMSD
RMSD

Reputation: 508

Enabling Executable Rule Models in a drools library

We have an old drools library that've been upgrading to later versions of KIE, and Executable rule models caught my eye. When I started my migration, my dependencies looked like this:

    <dependencies>
        ...
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mvel</groupId>
            <artifactId>mvel2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-api</artifactId>
            <version>${kie.version}</version>
        </dependency>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-ci</artifactId>
            <version>${kie.version}</version>
        </dependency>
    </dependencies>

 <build>
        <plugins>
            ...
            <plugin>
                <groupId>org.kie</groupId>
                <artifactId>kie-maven-plugin</artifactId>
                <version>${kie.version}</version>
                <extensions>true</extensions>
            </plugin>

Using 7.26.0.Final. When I upgraded to 7.59.0.Final I added the compiler dependency as I was supposed to from the doc:

        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-model-compiler</artifactId>
            <version>${kie.version}</version>
        </dependency>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-api</artifactId>
            <version>${kie.version}</version>
        </dependency>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-ci</artifactId>
            <version>${kie.version}</version>
        </dependency>

But my generate model now seems to fail:

[INFO] --- kie-maven-plugin:7.59.0.Final:generateModel (default-generateModel) @ rules ---
[INFO] Using NEW implementation
[INFO] Using NEW implementation
[INFO] Artifact not fetched from maven: org.drools:drools-model-compiler:7.59.0.Final. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.kie:kie-ci:7.59.0.Final. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.apache.commons:commons-collections4:4.4. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.apache.commons:commons-lang3:3.12.0. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.kie:kie-api:7.59.0.Final. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.mvel:mvel2:2.4.12.Final. To enable the KieScanner you need kie-ci on the classpath
WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[ERROR] Unable to build KieBaseModel:plan-rules
InvalidExpressionErrorResult: Method equalsAnyIgnoreCase on class org.apache.commons.lang3.StringUtils with arguments [class java.lang.String, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method intersectionsStartsWith on class com.accolade.clinical.utils.RuleUtils with arguments [interface java.util.List, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method size on class java.lang.Object with arguments [] is missing
... (A lot more errors of this nature)

Why won't it pick up the dependencies even if I have maven CI and the plugin configured? Is there something I missed in the docs?

Edit:

As per the the first answer:

I tried replacing the 3 dependencies I've listed above with

    <dependency>
        <groupId>org.drools</groupId>
        <artifactId>drools-engine</artifactId>
        <version>${kie.version}</version>
    </dependency>

But unfortunately kie doesn't want to use the new generate models method in this case:

[INFO] --- kie-maven-plugin:7.59.0.Final:generateModel (default-generateModel) @ rules ---
[WARNING] You're trying to build rule assets in a project from an executable rule model, but you did not provide the required dependency on the project classpath.
To enable executable rule models for your project, add the `drools-model-compiler` dependency in the `pom.xml` file of your project.

[INFO] 
[INFO] --- kie-maven-plugin:7.59.0.Final:generateDMNModel (default-generateDMNModel) @ rules ---
[INFO] 
[INFO] --- kie-maven-plugin:7.59.0.Final:generatePMMLModel (default-generatePMMLModel) @ rules ---
[WARNING] Skipping `generatePMMLModel` because you did not provide the required dependency on the project classpath.
To enable it for your project, add the `drools-model-compiler` dependency in the `pom.xml` file of your project.

[INFO] 
[INFO] --- kie-maven-plugin:7.59.0.Final:generateANC (default-generateANC) @ rules ---
[INFO] 
[INFO] --- kie-maven-plugin:7.59.0.Final:build (default-build) @ rules ---

Here's an output of mvn dependency:tree:

[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< com.mycompany:rules >---------------------
[INFO] Building Rules 5.0.0-SNAPSHOT
[INFO] --------------------------------[ kjar ]--------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ rules ---
[INFO] com.mycompany:rules:kjar:5.0.0-SNAPSHOT
[INFO] +- com.mycompany.acp.utilities:model-utilities:jar:7.1.0:compile
[INFO] |  +- com.mycompany.acp.fhir:common-fhir:jar:8.2.0:compile
[INFO] |  |  +- io.swagger.core.v3:swagger-annotations:jar:2.1.10:compile
[INFO] |  |  +- io.swagger:swagger-annotations:jar:1.6.2:compile
[INFO] |  |  +- org.reflections:reflections:jar:0.9.12:compile
[INFO] |  |  |  \- org.javassist:javassist:jar:3.26.0-GA:compile
[INFO] |  |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] |  |  |  \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] |  |  +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] |  |  |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  |  |  \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] |  |  \- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  +- com.github.java-json-tools:json-patch:jar:1.13:compile
[INFO] |  +- com.github.java-json-tools:msg-simple:jar:1.2:compile
[INFO] |  |  \- com.github.java-json-tools:btf:jar:1.3:compile
[INFO] |  +- com.github.java-json-tools:jackson-coreutils:jar:2.0:compile
[INFO] |  +- com.contentful.java:java-sdk:jar:10.4.5:compile
[INFO] |  |  +- com.squareup.retrofit2:retrofit:jar:2.5.0:compile
[INFO] |  |  +- com.squareup.retrofit2:adapter-rxjava2:jar:2.5.0:compile
[INFO] |  |  +- com.squareup.retrofit2:converter-gson:jar:2.5.0:compile
[INFO] |  |  +- io.reactivex.rxjava2:rxjava:jar:2.2.6:compile
[INFO] |  |  |  \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
[INFO] |  |  +- com.squareup.okhttp3:okhttp:jar:3.12.12:compile
[INFO] |  |  |  \- com.squareup.okio:okio:jar:1.15.0:compile
[INFO] |  |  +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] |  |  \- com.github.tony19:named-regexp:jar:0.2.5:compile
[INFO] |  +- com.mycompany.acp.resources:singularity-models:jar:6.1.0:compile
[INFO] |  |  +- com.mycompany.acp-common-eventbus:models:jar:5.0.3:compile
[INFO] |  |  |  \- com.amazonaws:aws-java-sdk-sns:jar:1.11.625:compile
[INFO] |  |  |     \- com.amazonaws:aws-java-sdk-sqs:jar:1.11.625:compile
[INFO] |  |  +- com.amazonaws:aws-java-sdk-dynamodb:jar:1.12.18:compile
[INFO] |  |  |  +- com.amazonaws:aws-java-sdk-s3:jar:1.12.18:compile
[INFO] |  |  |  |  \- com.amazonaws:aws-java-sdk-kms:jar:1.12.18:compile
[INFO] |  |  |  +- com.amazonaws:aws-java-sdk-core:jar:1.12.18:compile
[INFO] |  |  |  |  +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] |  |  |  |  |  \- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] |  |  |  |  +- software.amazon.ion:ion-java:jar:1.0.2:compile
[INFO] |  |  |  |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.12.3:compile
[INFO] |  |  |  |  \- joda-time:joda-time:jar:2.8.1:compile
[INFO] |  |  |  \- com.amazonaws:jmespath-java:jar:1.12.18:compile
[INFO] |  |  +- com.amazonaws:aws-java-sdk-sts:jar:1.12.18:compile
[INFO] |  |  \- com.mycompany.acp.fhir:common-utilities:jar:8.2.0:compile
[INFO] |  |     \- org.springframework:spring-web:jar:5.3.8:compile
[INFO] |  |        +- org.springframework:spring-beans:jar:5.3.8:compile
[INFO] |  |        \- org.springframework:spring-core:jar:5.3.8:compile
[INFO] |  |           \- org.springframework:spring-jcl:jar:5.3.8:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-databind:jar:2.12.4:compile
[INFO] |     +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.4:compile
[INFO] |     \- com.fasterxml.jackson.core:jackson-core:jar:2.12.4:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] +- commons-io:commons-io:jar:2.11.0:compile
[INFO] +- org.mvel:mvel2:jar:2.4.12.Final:compile
[INFO] +- org.slf4j:slf4j-api:jar:2.0.0-alpha5:provided
[INFO] +- org.projectlombok:lombok:jar:1.18.20:provided
[INFO] +- org.drools:drools-engine:jar:7.59.0.Final:compile
[INFO] |  +- org.kie:kie-api:jar:7.59.0.Final:compile
[INFO] |  |  \- org.kie.soup:kie-soup-maven-support:jar:7.59.0.Final:compile
[INFO] |  +- org.kie:kie-internal:jar:7.59.0.Final:compile
[INFO] |  +- org.drools:drools-core:jar:7.59.0.Final:compile
[INFO] |  |  +- org.kie.soup:kie-soup-xstream:jar:7.59.0.Final:compile
[INFO] |  |  +- org.drools:drools-core-reflective:jar:7.59.0.Final:compile
[INFO] |  |  +- org.drools:drools-core-dynamic:jar:7.59.0.Final:runtime
[INFO] |  |  \- commons-codec:commons-codec:jar:1.11:compile
[INFO] |  +- org.drools:drools-compiler:jar:7.59.0.Final:compile
[INFO] |  |  +- org.kie:kie-memory-compiler:jar:7.59.0.Final:compile
[INFO] |  |  +- org.drools:drools-ecj:jar:7.59.0.Final:compile
[INFO] |  |  +- org.antlr:antlr-runtime:jar:3.5.2:compile
[INFO] |  |  \- com.thoughtworks.xstream:xstream:jar:1.4.17:compile
[INFO] |  |     \- io.github.x-stream:mxparser:jar:1.2.1:compile
[INFO] |  |        \- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] |  \- org.drools:drools-model-compiler:jar:7.59.0.Final:compile
[INFO] |     +- org.drools:drools-canonical-model:jar:7.59.0.Final:compile
[INFO] |     +- com.github.javaparser:javaparser-core:jar:3.13.10:compile
[INFO] |     +- org.drools:drools-mvel-parser:jar:7.59.0.Final:compile
[INFO] |     \- org.drools:drools-mvel-compiler:jar:7.59.0.Final:compile
[INFO] +- xerces:xercesImpl:jar:2.12.1:test
[INFO] |  \- xml-apis:xml-apis:jar:1.4.01:test
[INFO] +- com.google.guava:guava:jar:30.1.1-jre:test
[INFO] |  +- com.google.guava:failureaccess:jar:1.0.1:test
[INFO] |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:test
[INFO] |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] |  +- org.checkerframework:checker-qual:jar:3.8.0:test
[INFO] |  +- com.google.errorprone:error_prone_annotations:jar:2.5.1:test
[INFO] |  \- com.google.j2objc:j2objc-annotations:jar:1.3:test
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.7.2:test
[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  \- org.junit.platform:junit-platform-commons:jar:1.7.2:test
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.7.2:test
[INFO] |  \- org.junit.platform:junit-platform-engine:jar:1.7.2:test
[INFO] \- org.junit.jupiter:junit-jupiter-params:jar:5.7.2:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.439 s
[INFO] Finished at: 2021-09-19T23:53:58-07:00
[INFO] ------------------------------------------------------------------------

Upvotes: 2

Views: 2157

Answers (1)

Luca Molteni
Luca Molteni

Reputation: 5370

Can you try using these new wrapper modules? They should solve your problem

" This issue is mainly caused by the fact that users have among their dependencies modules like drools-core and drools-compiler that in reality are no more than "internal implementation details". To avoid similar problems in future, in the very likely case that other modules will be introduced to split engine in finer grained submodules and descope optional features, the following 2 new wrapper modules have been created to cover the 2 different main usage scenarios:

drools-engine aggregating drools-core, drools-compiler and drools-model-compiler

drools-engine-classic aggregating drools-core, drools-compiler and drools-mvel "

If you want to use the executable model, use drools-engine

Edit:

The dependencies are correct, if you see this error message

InvalidExpressionErrorResult: Method equalsAnyIgnoreCase on class org.apache.commons.lang3.StringUtils with arguments [class java.lang.String, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method intersectionsStartsWith on class com.accolade.clinical.utils.RuleUtils with arguments [interface java.util.List, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method size on class java.lang.Object with arguments [] is missing

It means the executable model is compiling, but it's failing on some of your rules. We'll need a reproducer to see what's going on now. For example the line

InvalidExpressionErrorResult: Method size on class java.lang.Object with arguments [] is missing

Seems really strange as Object doesn't have a size() method.

Please file a bug on issues.redhat.com uploading your obfuscated rules so that we can investigate further.

Upvotes: 1

Related Questions