无法从java应用程序执行drools工作台规则

时间:2016-07-14 07:18:29

标签: jboss drools drools-guvnor kie kie-workbench

已安装的drools workbench 6.4.0工作台中的最终和定义的指导规则。

如果尝试从java应用程序执行规则,请获取以下异常。

    @RunWith(SpringJUnit4ClassRunner.class)
    @WebIntegrationTest("server.port:0")
    @SpringApplicationConfiguration(YourMainApplication.class)
    public class TestClass() {
        @Value("${local.server.port}")
        private int port;
    @Autowired
    private RestTemplate restTemplate;

   public <T> T get(String path, Class<T> responseType, Object... pathVariables) {
        return restTemplate.getForEntity(path, responseType, pathVariables).getBody();
    }

    }

关注了在线资源和相关问题,但仍无法解决问题。

This是其中一个相关链接。

我的java项目依赖项和配置文件。

Exception in thread "main" java.lang.RuntimeException: Cannot find KieModule: org.mydemo:myDemo:1.0
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:117)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:111)
at com.test.Test.main(Test.java:51)

  <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>
       <scope>provided</scope>
    </dependency>

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

    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-internal</artifactId>
      <version>6.4.0.Final</version>
       <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-api</artifactId>
      <version>6.4.0.Final</version>
       <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-templates</artifactId>
      <version>6.4.0.Final</version>
       <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-decisiontables</artifactId>
      <version>6.4.0.Final</version>
       <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.thoughtworks.xstream</groupId>
      <artifactId>xstream</artifactId>
      <version>1.4.3</version>
       <scope>provided</scope>
    </dependency>

我的Java代码:

<profile>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  <repositories>
    <repository>
      <id>guvnor-m2-repo</id>
      <name>Guvnor M2 Repo</name>
      <url>http://ip:8080/drools-wb/maven2/</url>
    </repository>
  </repositories>      
</profile>

任何人都可以帮助我,我是流口水的新手,花了将近2天的时间来解决这个问题。

1 个答案:

答案 0 :(得分:0)

它可能是您正在使用的网址,请尝试将其更改为:

http://ip:8080/drools-wb/maven2/org/mydemo/myDemo/1.0/myDemo-1.0.jar

即。 maven2不是maven2b

然后在网络浏览器中尝试。如果您需要身份验证,那么当Drools托管在Tomcat上并且已启用基本身份验证时,这适用于我。

    KieServices ks = KieServices.Factory.get();

    KieResources resources = ks.getResources();
    UrlResource urlResource = (UrlResource) resources.newUrlResource(url);
    urlResource.setUsername("admin");
    urlResource.setPassword("admin");
    urlResource.setBasicAuthentication("enabled");

我发现这篇博文很有帮助,即使您没有使用Spring,也可能对您有所帮助。

http://reypader.github.io/2016/01/06/spring-drools.html

相关问题