为什么加载Drools 6 KIE JAR到代码失败?

英文原文地址为: why does loading Drools 6 KIE JAR into code fail?

I'm using JBoss AS 7.1.1.Final with KIE Workbench/Drools 6.0.1., Java and Eclipse (Kepler).

我使用JBoss作为7.1.1。最后是KIE Workbench/Drools 6.0.1。,Java和Eclipse(开普勒)。

I need KIE Workbench (formerly Drools Guvnor) to let people graphically create/edit jars with Facts and Rules and then store as jars in the local maven repository. These jars (formerly pkg's) i want then to access programatically and load them into my Drools application. The app could even (although not preferedly) be run on the same workstation, so access to the repository could be

我需要KIE Workbench(前Drools Guvnor),让人们以图形的方式创建/编辑jar文件,并将它们作为jar存储在本地maven存储库中。这些jar(以前是pkg的)我想要编程并将它们加载到Drools应用程序中。该应用程序甚至可以(尽管不喜欢)在同一个工作站运行,因此可以访问存储库。

a) by URL: http://localhost:8080/drools-wb-as7.0/maven2/com/myprojects/myProject/LATEST/myProject-LATEST.jar

)的URL:http://localhost:8080 / drools-wb-as7.0 maven2 /com/myprojects/myProject/LATEST/myProject-LATEST.jar

b) by filepath/classpath: /my/folder/jboss-as-7.1.1.Final/bin/repositories/kie/com/myprojects/myProject/LATEST/myProject-LATEST.jar

b)filepath /类路径:/我的/文件夹/ jboss-as-7.1.1.Final / bin /仓库/ kie /com/myprojects/myProject/LATEST/myProject-LATEST.jar

I do NOT want to create/compile rules etc in my code, neither dynamically load a single .drl file dynamically - the prepared jar is what i need to load, with e.g. com.myprojects:myProject:LATEST as identifier.

我不想在我的代码中创建/编译规则,也不希望动态地加载一个.drl文件——我需要加载的是准备好的jar文件,比如com。最新myprojects:myProject:作为标识符。

I try this (according to documentation)

我尝试这个(根据文档)

KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.newKieContainer(
ks.newReleaseId("com.myprojects",   "myProject", "LATEST"));
KieScanner kScanner = ks.newKieScanner( kContainer );
kScanner.start( 10000L );

KieSession kSession = kContainer.newKieSession("defaultKieSession");
kSession.insert( fact );

[...]

[…]

However, this fails with the Runtime Exception,

但是,这在运行时异常中失败了,

Exception in thread "main" java.lang.RuntimeException: Cannot find KieModule: com.myprojects:myProject:LATEST
        at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:86)
        at com.myprojects.myproject.KieDroolsWBOnlinePuller.code(KieDroolsWBOnlinePuller.java:118)
        at com.myprojects.myproject.KieDroolsWBOnlinePuller.main(KieDroolsWBOnlinePuller.java:40)

My question is: Why is the jar from repo not found? Isn't the KieModule the representation of the jar and the jar automatically in the repo as I created it within KIE WB? Or must I change the default ReleaseID of the Maven Repo, which printed out with

我的问题是:为什么这个瓶子没有找到?KieModule不是在我在小WB中创建的,在repo中自动地表示jar和jar吗?或者,我必须更改Maven Repo的默认发布版本,它打印出来了。

KieRepository repo = ks.getRepository();
repo.getDefaultReleaseId()

resolves to

解析为

org.default:artifact:1.0.0-SNAPSHOT ?

Is it a Maven problem? What am I getting wrong?

这是一个Maven的问题吗?我哪里出错了?

Here the content of the jars pom.xml

这里是jar文件的内容。

<?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.myprojects</groupId>
  <artifactId>myProject</artifactId>
  <version>LATEST</version>
  <name>myProject</name>
  <repositories>
    <repository>
      <id>guvnor-m2-repo</id>
      <name>Guvnor M2 Repo</name>
      <url>http://localhost:8080/drools-wb-as7.0/maven2/</url>
    </repository>
  </repositories>
</project>

What I also tried was using this code to load the jar by URL:

我还尝试使用此代码通过URL加载jar:

KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("com.myprojects", "myProject", "LATEST");
KieResources kres = ks.getResources();

String url = "http://127.0.0.1:8080/drools-wb-as7.0/maven2/com/myprojects/myProject/LATEST/myProject-LATEST.jar";
kres.newUrlResource( url );
KieContainer kContainer = ks.newKieContainer(releaseId);
KieSession kSession = kContainer.newKieSession("statelessDefautlKnowledgeSession");
[...]

This failed with the same exception.... Any ideas?

这个失败的相同的异常....什么好主意吗?

Some Resources I read so far (can't post the other 6):

到目前为止,我读到的一些资源(不能发布其他6):

add drls etc. dynamically

动态添加drl等等

load drls dynamically

动态负载drl

1 个解决方案

#1


5  

In my case it turned out that

在我的案例中,事实证明。

<dependency>
  <groupId>org.kie</groupId>
  <artifactId>kie-ci</artifactId>
</dependency>

was missing in my POM

在我的POM里失踪了?


转载请注明本文地址: why does loading Drools 6 KIE JAR into code fail?

看完本文还有福利^-^:
20180512144120365
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值