我在执行流口水项目时遇到了这个错误。它是CEP用例的maven项目,并且pom.xml没有任何错误。我已经附加了我的kmodule.xml和java代码来获得我的KieSession实例。谁能告诉我我犯了什么错误?
同样,得到这个错误:无法解析ObjectType 'System.out。当我的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>
我想你是想写
rule "test pending cart item"
when
//conditions
$cart : CartObj( $status == "pending")
then
//actions
System.out.println("nPrint Pending Items Rule");
end
做一些输出的void方法调用不适合作为条件的一部分。
您必须指定kbase和ksession(在您的kmodule . xmlml中),并使用它来创建会话并激活规则。