调用KieScanner会抛出ClassNotFoundException

时间:2014-10-31 15:31:44

标签: maven drools wildfly-8 drools-guvnor kie

我有几个Drools项目,希望能够动态加载规则更改。这些项目都运行良好,直到我尝试将KieScanner添加到它们。我按照这里的指示:http://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html/DroolsReleaseNotesChapter.html#d0e515

我正在使用drools 6.1.0.Final和Wildfly 8.0.0.Final

文档表明在我的类路径中具有kie-ci的依赖性就足够了。显然我要么做错了,要么文档错了。

项目构建但是当它被调用时,我得到了这个痕迹:

10:21:17,946 ERROR [io.undertow.request](默认任务-2)UT005023:对/ catalog / vetec / search / facets / term的异常处理请求:org.jboss.resteasy.spi.UnhandledException:javax .enterprise.inject.CreationException     at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)[resteasy-jaxrs-3.0.6.Final.jar:]     at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)[resteasy-jaxrs-3.0.6.Final.jar:]     at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149)[resteasy-jaxrs-3.0.6.Final.jar:]     在org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372)[resteasy-jaxrs-3.0.6.Final.jar:]     在org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)[resteasy-jaxrs-3.0.6.Final.jar:]

引起:java.lang.NoClassDefFoundError:org / apache / maven / repository / internal / MavenRepositorySystemSession     在org.kie.scanner.MavenRepository.getMavenRepository(MavenRepository.java:73)[kie-ci-6.1.0.Final.jar:6.1.0.Final]     在org.kie.scanner.ArtifactResolver。(ArtifactResolver.java:36)[kie-ci-6.1.0.Final.jar:6.1.0.Final]     at org.kie.scanner.KieRepositoryScannerImpl.getArtifactResolver(KieRepositoryScannerImpl.java:87)[kie-ci-6.1.0.Final.jar:6.1.0.Final]     在org.kie.scanner.KieRepositoryScannerImpl.getArtifactVersion(KieRepositoryScannerImpl.java:108)[kie-ci-6.1.0.Final.jar:6.1.0.Final]     at org.drools.compiler.kie.builder.impl.KieRepositoryImpl $ KieModuleRepo.load(KieRepositoryImpl.java:281)[drools-compiler-6.1.0.Final.jar:6.1.0.Final]     at org.drools.compiler.kie.builder.impl.KieRepositoryImpl $ KieModuleRepo.load(KieRepositoryImpl.java:267)[drools-compilder-6.1.0.Final.jar:6.1.0.Final]     at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:90)[drools-compiler-6.1.0.Final.jar:6.1.0.Final]     at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:77)[drools-compiler-6.1.0.Final.jar:6.1.0.Final]     at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:97)[drools-compiler-6.1.0.Final.jar:6.1.0.Final]     在com.sial.rules.cdi.KSessionContextProvider。(KSessionContextProvider.java:49)[sial-rules-0.0.1-SNAPSHOT.jar:]

这是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>com.sial.rules</groupId>
  <artifactId>sial-rules</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <repositories>
    <repository>
        <id>JBoss Repository</id>
        <url>https://repository.jboss.org/nexus/content/groups/public/</url>
    </repository>
  </repositories>   
   <dependencyManagement>
    <dependencies>
    <!-- Added to ensure that we have the correct DROOLS/JBOSS versions -->
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-bom</artifactId>
            <version>6.1.0.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
       <dependency>
            <groupId>org.wildfly.bom</groupId>
            <artifactId>jboss-javaee-7.0-with-tools</artifactId>
            <version>8.0.0.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency> 
        <dependency>
            <groupId>org.wildfly.bom</groupId>
            <artifactId>jboss-javaee-7.0-with-resteasy</artifactId>
            <version>8.0.0.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>    
    </dependencies>
  </dependencyManagement>
  <dependencies>
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
        </dependency>        
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
        </dependency>  
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-core</artifactId>
        </dependency>                        
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-compiler</artifactId>
        </dependency>       
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-decisiontables</artifactId>
        </dependency>       
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-persistence-jpa</artifactId>
        </dependency>                   
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>knowledge-api</artifactId>
        </dependency>       
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-internal</artifactId>
        </dependency>       
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-api</artifactId>
        </dependency>    
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-ci</artifactId>
                      <exclusions>
                        <exclusion>
                           <groupId>org.jboss.netty</groupId>
                           <artifactId>netty</artifactId>
                        </exclusion>
                      </exclusions>
        </dependency>


        <dependency>
          <groupId>org.codehaus.jackson</groupId>
          <artifactId>jackson-core-asl</artifactId>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.codehaus.jackson</groupId>
          <artifactId>jackson-mapper-asl</artifactId>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.logging.log4j</groupId>
          <artifactId>log4j-api</artifactId>
          <version>2.0-rc1</version>
          <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
  </dependencies>  
  <build>
     <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
         <groupId>org.drools</groupId>
         <artifactId>drools-maven-plugin</artifactId>
         <version>6.0.0.CR5</version>
         <extensions>true</extensions>
      </plugin>
     </plugins>
  </build> 
</project>

此业务规则项目本身已合并到部署到Wildfly的实际WAR中。这是应用程序poms中使用的依赖项:

        <dependency>
            <groupId>com.sial.rules</groupId>
            <artifactId>sial-rules</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

我最近发现额外的依赖性破坏了我们的Arquillian Unit测试。由于Arquillian有一个完全不同的maven集成,我最好的猜测是这是KIE中的一个错误。它与BZ1098018

非常相似

当代码实际调用kie-ci时,添加这个额外的依赖项“修复”了问题,但是由于这种依赖性,我们的Arquillian测试无法部署。

<dependency>
   <groupId>org.apache.maven</groupId>
   <artifactId>maven-aether-provider</artifactId>
   <version>3.0.5</version>
</dependency>

2 个答案:

答案 0 :(得分:0)

问题是kie-ci包含旧版本的maven(3.0.5)而不是Arquillian(3.1.1)特别是maven-aether-provider。 Arquillian(真正的ShrinkWrap)真的想要使用更新的版本。

我尝试在pom.xml中强制使用3.0.5版本但是得到了解析器的问题。 这是错误: java.lang.UnsupportedOperationException:无法boostrap Aether存储库系统。确保您正在运行Maven 3.1.0或更高版本。

所以基本上是kie 6.1.0.Final与Arquillian 1.1.5.Final不相容

我将不得不看看Kie 6.2.0CR3版本是否可行

答案 1 :(得分:0)

您不需要手动声明其他maven,以太和其他依赖项。 kie-ci应该过渡依赖于它所需要的一切。如果你查看kie-ci https://github.com/droolsjbpm/drools/blob/6.1.0.Final/kie-ci/pom.xml的pom.xml,你添加的依赖项也会列在那里,所以Maven会自动解析它们。

这似乎是一些奇怪的错误或错误配置。我认为你的pom中有以下内容:

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

你能发贴你的整个pom吗?