我刚开始学习Drools,我遇到了一个问题。
我正在开发一个涉及Java 7和Drools 6.3.0.Final的项目。我想要KieScanner的加载规则,规则jar是droolsrules-1.0.0-RELEASE.jar
:
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("com.ericsson", "droolsrules", "1.0.0-Final");
KieContainer kc = ks.newKieContainer( releaseId );
KieScanner kScanner = ks.newKieScanner(kc);
// Start the KieScanner polling the Maven repository every 10 seconds
kScanner.start(10000L);
KieSession ksession = kc.newKieSession("GeelyKS");
QueryResults qr = null;
while(true){
System.out.print("Please enter Param:");
s = br.readLine();
if(s == null || s.trim().length() == 0){
continue;
}
if (!s.equals("exit")) {
String[] ss = s.split(",");
Param param = new Param();
param.setName(ss[0]);
param.setValue(ss[1]);
param.setAction(ss[2]);
ksession.insert(param);
ksession.fireAllRules();
qr = ksession.getQueryResults("query fact count");
System.out.println("param project count:" + qr.size());
当我运行项目时,我遇到了以下错误:
java.lang.RuntimeException: org.kie.scanner.embedder.MavenEmbedderException: Failed to read artifact descriptor for org.kie:kie-api:jar:6.3.0.Final
at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:57)
at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:49)
at org.kie.scanner.ArtifactResolver.getResolverFor(ArtifactResolver.java:127)
at org.kie.scanner.ArtifactResolver.getResolverFor(ArtifactResolver.java:90)
at org.kie.scanner.KieRepositoryScannerImpl.setKieContainer(KieRepositoryScannerImpl.java:88)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieScanner(KieServicesImpl.java:139)
at com.ericsson.geely.service.impl.ParamServiceImpl.alarmTest(ParamServiceImpl.java:32)
at com.ericsson.geely.main.AppMain.main(AppMain.java:18)
Caused by: org.kie.scanner.embedder.MavenEmbedderException: Failed to read artifact descriptor for org.kie:kie-api:jar:6.3.0.Final
at org.kie.scanner.embedder.MavenEmbedder.readProject(MavenEmbedder.java:276)
at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:55)
... 7 more
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.kie:kie-api:jar:6.3.0.Final
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:384)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:231)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:525)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:509)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:409)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:363)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:351)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:254)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:316)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:159)
at org.apache.maven.project.DefaultProjectBuilder.resolveDependencies(DefaultProjectBuilder.java:202)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:175)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:114)
at org.kie.scanner.embedder.MavenEmbedder.readProject(MavenEmbedder.java:271)
... 8 more
当我不使用KieScanner时,它可以很好地工作 我该如何解决?
答案 0 :(得分:0)
它看起来像你指定的jar文件" droolsrules- 1.0.0-RELEASE .jar"它上面有一个不同于你的代码试图检索的版本标记:" 1.0.0-Final "。该版本是否真的匹配?
您可以尝试将版本范围指定为KIE而不是特定版本。我认为KieScanner无法解决特定的发行版本。您可以使用SNAPSHOT版本,LATEST,RELEASE或类似[1.0.0-FINAL,1.1.0)的范围