创建了Drools Kie会话,我得到了这个“类未找到异常”。 [英] Created drools Kie session and I get this "class not found exception"
本文介绍了创建了Drools Kie会话,我得到了这个“类未找到异常”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对流口水并不陌生,对其进行了测试以创建kie会话,而当我尝试这样做时,却遇到此错误。按照本教程进行操作
I am new to drools, testing it out to create kie session and while I tried to do that, I get this error. Followed this tutorial to do it
http://javainuse.com/drools_hello_kie
我的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.javainuse</groupId>
<artifactId>drools-hello-world</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<drools.version>6.2.0.Final</drools.version>
</properties>
<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.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>6.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>6.2.0.Final</version>
</dependency>
</dependencies>
</project>
我的主要班级是这个
package main;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
import stateful.Product;
public class StatefulMain {
public static final void main(String[] args) {
try {
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
//Get the session named kseesion-rule that we defined in kmodule.xml above.
//Also by default the session returned is always stateful.
KieSession kSession = kContainer.newKieSession("ksession-rule");
Product product = new Product();
product.setType("gold");
FactHandle fact1;
fact1 = kSession.insert(product);
kSession.fireAllRules();
System.out.println("The discount for the jewellery product "
+ product.getType() + " is " + product.getDiscount());
} catch (Throwable t) {
t.printStackTrace();
}
}
}
我的错误是
java.lang.ExceptionInInitializerError
at main.StatefulMain.main(StatefulMain.java:14)
Caused by: java.lang.RuntimeException: Unable to instance KieServices
at org.kie.api.KieServices$Factory.<clinit>(KieServices.java:233)
... 1 more
Caused by: java.lang.ClassNotFoundException: org.drools.compiler.kie.builder.impl.KieServicesImpl
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.kie.api.KieServices$Factory.<clinit>(KieServices.java:231)
... 1 more
有人可以帮助解释为什么会这样吗?我添加了主类,pom文件和我得到的错误。我无法找出错误所在。我对上面的链接进行了逐步实现。
Can anyone help with why this could be happening? I added the main class, the pom file and my error what I get. I am not able to figure out where the error lies. I did a step by step implementation of the link above.
推荐答案
请在您的POM.xml中添加以下依赖项
Please add the below dependency into your POM.xml
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
<version>6.2.0.Final</version>
</dependency>
这篇关于创建了Drools Kie会话,我得到了这个“类未找到异常”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文