Drools无法从InputStream创建MavenProject

时间:2018-01-17 12:15:12

标签: java maven drools drools-kie-server

我有一个Drools决策表实现,可以在我的开发机器上运行,但不能在云中部署到我的VM。现在这表明存在部署问题,但对于我的生活,我无法看到问题所在。

uk.co.example.equi.e​​quiClient的第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

这是与kie相关的pom.xml部分。

    <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(); 

1 个答案:

答案 0 :(得分:0)

我也遇到了同样的错误。添加以下依赖关系为我解决了这个问题:     <% content_for :javascript_includes do %> <%= javascript_include_tag "charges.js" %> <% end %> <style> #pageBox { width: 600px; margin: 60px auto; } .header { text-align: center } .content { margin-top: 50px; } </style> </div>