获取错误org.drools.compiler.kie.builder.impl.AbstractKieModule - 无法构建KieBaseModel:defaultKieBase

时间:2015-10-18 16:44:30

标签: java maven drools kie

我在执行drools项目时遇到此错误。它是CEP用例的maven项目,pom.xml没有任何错误。我附加了我的kmodule.xml和java代码来获取我的KieSession实例。有人能告诉我我犯了什么错误吗?

此外,收到此错误:无法解析ObjectType' System.out.println'当我的drl被执行。

kmodule.xml

<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">

</kmodule>

Java代码示例:

KieServices ks = KieServices.Factory.get();

 KieContainer kieContainer = ks.getKieClasspathContainer();
 KieBaseConfiguration config = ks.newKieBaseConfiguration();
 config.setOption( EventProcessingOption.STREAM );

 KieBase kieBase = kieContainer.newKieBase( config );

 kSession = kieBase.newKieSession();

Drl文件:

rule "test pending cart item"
no-loop
when
//conditions
System.out.println("\nPrint Pending Items Rule");
$cart : CartObj( $status == "pending")

then
//actions

end

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.org.testdemo</groupId>
    <artifactId>testdemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-api</artifactId>
            <version>6.2.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-core</artifactId>
            <version>6.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20150729</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.paho</groupId>
            <artifactId>mqtt-client</artifactId>
            <version>0.4.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.4</version>
        </dependency>
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-compiler</artifactId>
            <version>6.2.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.2</version>
        </dependency>
    </dependencies>
</project>

2 个答案:

答案 0 :(得分:1)

我想你打算写

rule "test pending cart item"
when
    //conditions
    $cart : CartObj( $status == "pending")
then
    //actions
    System.out.println("\nPrint Pending Items Rule");
end

执行某些输出的void方法调用不适合作为条件的一部分。

答案 1 :(得分:0)

你必须证明kbase和ksession(在你的kmoudle.xmkl中),并使用它来创建一个会话并解雇你的规则。