droolsquarkuskiekogito

Kogito+Quarkus TMS Problem - You're trying to use the Truth Maintenance System without having imported it


I'm trying to create a drools project with kogito and quarkus, some rules have an "InsertLogical" in its consecuence, but I can't figure out how to make the proyect work using the TruthMaintenanceSystem, i have tried multiple "solutions" but none of them worked, i always get the error:

org.drools.core.common.MissingDependencyException: You're trying to use the Truth Maintenance System without having imported it. Please add the module org.drools:drools-tms to your classpath.
    at org.drools.core.common.TruthMaintenanceSystemFactory.throwExceptionForMissingTms(TruthMaintenanceSystemFactory.java:51)
    at org.drools.kiesession.consequence.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:144)
    at org.drools.kiesession.consequence.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:139)
    at org.kie.kogito.legacy.PF3.LambdaConsequenceF352674214CBCA67851227756FDB4204.execute(LambdaConsequenceF352674214CBCA67851227756FDB4204.java:23)
    at org.kie.kogito.legacy.PF3.LambdaConsequenceF352674214CBCA67851227756FDB4204.execute(LambdaConsequenceF352674214CBCA67851227756FDB4204.java:10)
    at org.drools.model.functions.Block1$Impl.execute(Block1.java:40)
    at org.drools.modelcompiler.consequence.LambdaConsequence.evaluate(LambdaConsequence.java:68)
    at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:423)
    at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:370)
    at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:158)
    at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:110)
    at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33)
    at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
    at org.drools.kiesession.agenda.DefaultAgenda.fireLoop(DefaultAgenda.java:698)
    at org.drools.kiesession.agenda.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:645)
    at org.drools.kiesession.agenda.DefaultAgenda.fireAllRules(DefaultAgenda.java:637)
    at org.drools.kiesession.session.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1117)
    at org.drools.kiesession.session.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1108)
    at org.drools.kiesession.session.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1092)

I took this project as reference: rules-legacy-quarkus-example

and added the required drools-tms dependency.

A dummy example of the problematic rule:

package org.kie.kogito.legacy;

import org.kie.kogito.legacy.LoanApplication;
import org.kie.kogito.legacy.Applicant;

global Integer maxAmount;
global java.util.List approvedApplications;

rule SmallDepositApprove when
    $l: LoanApplication( applicant.age >= 20, deposit < 1000, amount <= 2000 )
then
    insertLogical(new Applicant("test", 24));
end

The pom.xml (it`s the same from the base example with drools-tms and drools-xml-support)

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
    
  <groupId>com.test</groupId>
  <version>1.36.1.Final</version>
  <artifactId>rules-legacy-quarkus-example</artifactId>
  <name>Kogito Example :: Rules Legacy API - Quarkus</name>
  
  
  <properties>
      <maven.compiler.source>17</maven.compiler.source>
      <maven.compiler.target>17</maven.compiler.target>
    <quarkus-plugin.version>2.16.4.Final</quarkus-plugin.version>
    <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
    <quarkus.platform.version>2.16.4.Final</quarkus.platform.version>
    <kogito.bom.group-id>org.kie.kogito</kogito.bom.group-id>
    <kogito.bom.artifact-id>kogito-bom</kogito.bom.artifact-id>
    <kogito.bom.version>1.36.1.Final</kogito.bom.version>
    <version.org.kie.kogito>1.36.1.Final</version.org.kie.kogito>
    <drools.version>8.36.0.Final</drools.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>${quarkus.platform.group-id}</groupId>
        <artifactId>${quarkus.platform.artifact-id}</artifactId>
        <version>${quarkus.platform.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>${kogito.bom.group-id}</groupId>
        <artifactId>${kogito.bom.artifact-id}</artifactId>
        <version>${kogito.bom.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.kie.kogito</groupId>
      <artifactId>kogito-quarkus-rules</artifactId>
    </dependency>
     <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-tms</artifactId>
      <version>${drools.version}</version>
    </dependency>
    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-xml-support</artifactId>
      <version>${drools.version}</version>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-jackson</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-arc</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-openapi</artifactId>
    </dependency>
    <dependency>
      <groupId>org.kie.kogito</groupId>
      <artifactId>kogito-drools</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-health</artifactId>
    </dependency>
  </dependencies>
  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>${quarkus.platform.group-id}</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
        <version>${quarkus-plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Solution

  • It seems reproducible on latest, where added org.drools:drools-tms but seems the DefaultKnowledgeHelper is always invoked instead of going via the service loader at least because of this.

    Currently tracked with https://issues.redhat.com/browse/KOGITO-9141

    I'd suggest subscribe to that JIRA in order to follow-up on the updates on the current investigations.

    Thank you for reporting.