KieScanner和Spark com.google.inject.ProvisionException:Guice供应错误

时间:2016-08-29 19:56:03

标签: maven apache-spark guice drools kie

将KieScanner与我的Drools + Spark程序一起使用时,我收到此Guice Provision错误。我使用Spark 1.6.2与Drools和Kie-cl 6.4.0,我正在从我当地的maven存储库中读取我的口水规则。当我ks.newKieScanner(kieContainer)时,spark应用程序运行并运行;被删除,因此在实施时似乎存在问题。

代码初始化KieScanner:



    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId("DroolsDynamic.group", "DroolsDynamic.artifact", "1.0-SNAPSHOT");
    KieContainer kieContainer = ks.newKieContainer( releaseId );
    KieSession kSession = kieContainer.newKieSession("ksession-rules");
    KieScanner kScanner = ks.newKieScanner( kieContainer );

Guice Provision Exception:


    Exception in thread "main" java.lang.RuntimeException: org.kie.scanner.embedder.MavenEmbedderException: **com.google.inject.ProvisionException: Guice provision errors:**

    1) No implementation for org.apache.maven.repository.RepositorySystem was bound.
      while locating org.apache.maven.execution.DefaultMavenExecutionRequestPopulator
      at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]]
      at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]]
      while locating org.apache.maven.execution.MavenExecutionRequestPopulator

    1 error
          role: org.apache.maven.execution.MavenExecutionRequestPopulator
      roleHint: 
        at org.kie.scanner.embedder.MavenProjectLoader.newMavenEmbedder(MavenProjectLoader.java:69)
        at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:53)
        at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:49)
        at org.kie.scanner.ArtifactResolver.getResolverFor(ArtifactResolver.java:136)
        at org.kie.scanner.ArtifactResolver.getResolverFor(ArtifactResolver.java:99)
        at org.kie.scanner.KieRepositoryScannerImpl.setKieContainer(KieRepositoryScannerImpl.java:89)
        at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieScanner(KieServicesImpl.java:139)
        at com.sample.SnortTest.main(SnortTest.java:72)
        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:497)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
    Caused by: org.kie.scanner.embedder.MavenEmbedderException: com.google.inject.ProvisionException: Guice provision errors:

    1) No implementation for org.apache.maven.repository.RepositorySystem was bound.
      while locating org.apache.maven.execution.DefaultMavenExecutionRequestPopulator
      at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]]
      at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]]
      while locating org.apache.maven.execution.MavenExecutionRequestPopulator

    1 error
          role: org.apache.maven.execution.MavenExecutionRequestPopulator
      roleHint: 
        at org.kie.scanner.embedder.MavenEmbedder.(MavenEmbedder.java:102)
        at org.kie.scanner.embedder.MavenEmbedder.(MavenEmbedder.java:81)
        at org.kie.scanner.embedder.MavenEmbedder.(MavenEmbedder.java:75)
        at org.kie.scanner.embedder.MavenProjectLoader.newMavenEmbedder(MavenProjectLoader.java:66)
        ... 16 more
    Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: Guice provision errors:

    1) No implementation for org.apache.maven.repository.RepositorySystem was bound.
      while locating org.apache.maven.execution.DefaultMavenExecutionRequestPopulator
      at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]]
      at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]]
      while locating org.apache.maven.execution.MavenExecutionRequestPopulator

    1 error
          role: org.apache.maven.execution.MavenExecutionRequestPopulator
      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.buildMavenExecutionRequest(MavenEmbedder.java:119)
        at org.kie.scanner.embedder.MavenEmbedder.(MavenEmbedder.java:90)
        ... 19 more
    Caused by: com.google.inject.ProvisionException: Guice provision errors:

    1) No implementation for org.apache.maven.repository.RepositorySystem was bound.
      while locating org.apache.maven.execution.DefaultMavenExecutionRequestPopulator
      at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]]
      at ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]]
      while locating org.apache.maven.execution.MavenExecutionRequestPopulator

    1 error
        at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:987)
        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)
        ... 24 more

这是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>DroolsDynamic.group</groupId>
      <artifactId>DroolsDynamic.artifact</artifactId>
      <version>1.0</version>
      <packaging>jar</packaging>



        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>


        <dependencies>
            <dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-streaming_2.10</artifactId>
                <version>1.6.2</version>
            </dependency>

            <dependency>
                <groupId>org.kie</groupId>
                <artifactId>kie-ci</artifactId>
                <version>6.4.0.Final</version>
            </dependency>

            <dependency>
                <groupId>org.drools</groupId>
                <artifactId>drools-compiler</artifactId>
                <version>6.4.0.Final</version>
            </dependency>

            <dependency>
                <groupId>org.drools</groupId>
                <artifactId>drools-core</artifactId>
                <version>6.4.0.Final</version>
            </dependency>
        </dependencies>

      <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <filters>
                <filter>
                    <artifact>*:*</artifact>
                    <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                    </excludes>
                </filter>
            </filters>
            <!-- Additional configuration. -->
                </configuration>
                <executions>
                  <execution>
                    <phase>package</phase>
                    <goals>
                      <goal>shade</goal>
                    </goals>
                  </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
          <id>kinesis-asl</id>
          <dependencies>
            <dependency>
              <groupId>org.apache.spark</groupId>
              <artifactId>spark-streaming-kinesis-asl_${scala.binary.version}</artifactId>
              <version>${project.version}</version>
              <scope>provided</scope>
            </dependency>
          </dependencies>
        </profile>
      </profiles>
    </project>

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>DroolsDynamic.group</groupId> <artifactId>DroolsDynamic.artifact</artifactId> <version>1.0</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-streaming_2.10</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>org.kie</groupId> <artifactId>kie-ci</artifactId> <version>6.4.0.Final</version> </dependency> <dependency> <groupId>org.drools</groupId> <artifactId>drools-compiler</artifactId> <version>6.4.0.Final</version> </dependency> <dependency> <groupId>org.drools</groupId> <artifactId>drools-core</artifactId> <version>6.4.0.Final</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.4.3</version> <configuration> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> <!-- Additional configuration. --> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>kinesis-asl</id> <dependencies> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-streaming-kinesis-asl_${scala.binary.version}</artifactId> <version>${project.version}</version> <scope>provided</scope> </dependency> </dependencies> </profile> </profiles> </project>

我已经坚持了一段时间来更改pom.xml等等,而且我仍然卡住了。任何帮助或想法为什么会发生这种情况会有所帮助。谢谢!

2 个答案:

答案 0 :(得分:1)

我遇到了这个问题,或者就像它一样。为了解决这个问题,我添加了以下阴影插件&#34;变形金刚&#34;部分:

<transformers>
    <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer" >
        <resource>META-INF/sisu/javax.inject.Named</resource>
    </transformer>
</transformers>

我相信我在网上其他地方找到了这个答案,但我不知道在哪里。

答案 1 :(得分:0)

我记得有同样的问题,在我的情况下,它通过在我的项目中添加以下依赖项来解决:

    <dependency>
        <groupId>org.eclipse.aether</groupId>
        <artifactId>aether-impl</artifactId>
        <version>1.1.0</version>
    </dependency>

我猜也可以使用除以太之外的其他实现。

希望它有所帮助,