我有一个 Drools 决策表实现,可以在我的开发机器上运行,但在部署到云中的 VM 时却不行。现在这表明存在部署问题,但对于我来说,我看不出问题出在哪里。
uk.co.example.equi.equiClient 的第 321 行是 kbuilder.buildAll();
这是我得到的错误:
E 16:47:28:172;DispatcherThread 1;org.kie.api.builder.KieScanner Unable to create new MavenEmbedder
EXC:
org.kie.scanner.embedder.MavenEmbedderException: com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) No implementation for org.apache.maven.execution.scope.internal.MojoExecutionScope was bound.
while locating org.apache.maven.plugin.DefaultBuildPluginManager
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.plugin.BuildPluginManager
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.lifecycle.internal.MojoDescriptorCreator
while locating org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.lifecycle.internal.LifecycleStarter
while locating org.apache.maven.DefaultMaven
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.Maven
1 error
role: org.apache.maven.Maven
roleHint:
at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:107)
at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:86)
at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:80)
at org.kie.scanner.embedder.MavenProjectLoader.newMavenEmbedder(MavenProjectLoader.java:77)
at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:61)
at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:55)
at org.kie.scanner.MavenPomModelGenerator.parse(MavenPomModelGenerator.java:33)
at org.drools.compiler.kproject.xml.PomModel$Parser.parse(PomModel.java:110)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildPomModel(KieBuilderImpl.java:471)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getPomModel(KieBuilderImpl.java:448)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.init(KieBuilderImpl.java:134)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:169)
at uk.co.example.equi.EquiClient.setup(EquiClient.java:321)
at uk.co.example.equi.EquiService.init(EquiService.java:149)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.nustaq.kontraktor.impl.DispatcherThread.invoke(DispatcherThread.java:363)
at org.nustaq.kontraktor.impl.DispatcherThread.pollQs(DispatcherThread.java:291)
at org.nustaq.kontraktor.impl.DispatcherThread.pollQs(DispatcherThread.java:264)
at org.nustaq.kontraktor.impl.DispatcherThread.run(DispatcherThread.java:164)
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) No implementation for org.apache.maven.execution.scope.internal.MojoExecutionScope was bound.
while locating org.apache.maven.plugin.DefaultBuildPluginManager
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.plugin.BuildPluginManager
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.lifecycle.internal.MojoDescriptorCreator
while locating org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.lifecycle.internal.LifecycleStarter
while locating org.apache.maven.DefaultMaven
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.Maven
1 error
role: org.apache.maven.Maven
roleHint:
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:249)
at org.kie.scanner.embedder.PlexusComponentProvider.lookup(PlexusComponentProvider.java:42)
at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:97)
... 21 more
Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) No implementation for org.apache.maven.execution.scope.internal.MojoExecutionScope was bound.
while locating org.apache.maven.plugin.DefaultBuildPluginManager
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.plugin.BuildPluginManager
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.lifecycle.internal.MojoDescriptorCreator
while locating org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.lifecycle.internal.LifecycleStarter
while locating org.apache.maven.DefaultMaven
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.Maven
1 error
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1018)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
... 25 more
这是 pom.xml 中与 kie 相关的部分。
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${drools.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
<version>${drools.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>${drools.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
这是代码
KieServices kieServices = KieServices.Factory.get();
KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
Resource resource = kieServices.getResources().newClassPathResource("dtables/applylncc.xlsx");
// create compiler class instance
SpreadsheetCompiler sc = new SpreadsheetCompiler();
kieFileSystem.write(resource);
KieBuilder kbuilder = kieServices.newKieBuilder(kieFileSystem);
kbuilder.buildAll();
KieRepository kieRepository = kieServices.getRepository();
KieContainer kContainer = kieServices.newKieContainer(kieRepository.getDefaultReleaseId());
applySession = kContainer.newKieSession();