为什么将Drools 6 KIE JAR加载到代码失败? [英] why does loading Drools 6 KIE JAR into code fail?

查看:1026
本文介绍了为什么将Drools 6 KIE JAR加载到代码失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JBoss AS 7.1.1.Final和KIE Workbench / Drools 6.0.1。,Java和Eclipse(Kepler)。

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

我需要KIE Workbench(以前称为Drools Guvnor)让人们用Facts和Rules以图形方式创建/编辑罐子,然后将其作为jar存储在本地maven存储库中。这些罐子(以前称为pkg)然后我想以编程方式访问并将它们加载到我的Drools应用程序中。该应用程序甚至可以(虽然不是优先)在同一工作站上运行,因此访问存储库可以

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

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

b)按文件路径/类路径:
/my/folder/jboss-as-7.1.1.Final/bin/repositories/kie/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

创建/编译我的代码中的规则等,既不动态动态加载单个.drl文件 - 准备好的jar是我需要加载的,用
例如com.myprojects:myProject:LATEST as identifier。

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.

我试试这个(根据文档)

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)

我的问题是:为什么没有找到回购的jar?当我在KIE WB中创建时,KieModule不是回购中jar和jar的表示吗?
或者我必须更改Maven Repo的默认ReleaseID,其中打印出

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

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

解析为

org.default:artifact:1.0.0-SNAPSHOT ?

这是Maven问题吗?我错了什么?

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

这里的罐子内容pom.xml

Here the content of the jars pom.xml

<?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>

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

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

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?

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

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

动态添加drls等

动态加载drls

load drls dynamically

推荐答案

在我的结果发现

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

我的POM中缺少

was missing in my POM

这篇关于为什么将Drools 6 KIE JAR加载到代码失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆