2016-07-27 101 views
0

我嘗試從我在KIE工作臺上創建的項目獲取kieContainer。如何從KIE工作臺獲得kieContainer

String url = "http://dev.dsack.local:8080/kie-wb/maven2wb/ouTest/projectTest/1.0/projectTest-1.0.jar"; 
    ReleaseIdImpl releaseId = new ReleaseIdImpl("ouTest", "projectTest", "1.0"); 
    KieServices kieServices = KieServices.Factory.get(); 
    kieServices.getResources().newUrlResource(url); 
    KieContainer kieContainer = kieServices.newKieContainer(releaseId); 

當我打開一個瀏覽器的網址,我可以下載的.jar 但在最後一行我得到一個錯誤。我不知道我做錯了什麼。我對maven也不是很熟悉。你能幫我麼?

12:57:11.688 [main] DEBUG org.kie.scanner.MavenRepository - Unable to resolve artifact: ouTest:projectTest:pom:1.0 
org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact ouTest:projectTest:pom:1.0 in central (https://repo.maven.apache.org/maven2) 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444) ~[aether-impl-1.0.0.v20140518.jar:na] 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246) ~[aether-impl-1.0.0.v20140518.jar:na] 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223) ~[aether-impl-1.0.0.v20140518.jar:na] 
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:294) ~[aether-impl-1.0.0.v20140518.jar:na] 
at org.kie.scanner.MavenRepository.resolveArtifact(MavenRepository.java:154) ~[kie-ci-6.4.0.Final.jar:6.4.0.Final] 
at org.kie.scanner.ArtifactResolver.getPomFileForGAV(ArtifactResolver.java:148) [kie-ci-6.4.0.Final.jar:6.4.0.Final] 
at org.kie.scanner.ArtifactResolver.getResolverFor(ArtifactResolver.java:108) [kie-ci-6.4.0.Final.jar:6.4.0.Final] 
at org.kie.scanner.KieRepositoryScannerImpl.loadPomArtifact(KieRepositoryScannerImpl.java:151) [kie-ci-6.4.0.Final.jar:6.4.0.Final] 
at org.kie.scanner.KieRepositoryScannerImpl.loadArtifact(KieRepositoryScannerImpl.java:127) [kie-ci-6.4.0.Final.jar:6.4.0.Final] 
at org.kie.scanner.KieRepositoryScannerImpl.loadArtifact(KieRepositoryScannerImpl.java:122) [kie-ci-6.4.0.Final.jar:6.4.0.Final] 
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.loadKieModuleFromMavenRepo(KieRepositoryImpl.java:130) [drools-compiler-6.4.0.Final.jar:6.4.0.Final] 
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:116) [drools-compiler-6.4.0.Final.jar:6.4.0.Final] 
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:93) [drools-compiler-6.4.0.Final.jar:6.4.0.Final] 
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:115) [drools-compiler-6.4.0.Final.jar:6.4.0.Final] 
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:111) [drools-compiler-6.4.0.Final.jar:6.4.0.Final] 
at controller.DecisionServerTest.test2(DecisionServerTest.java:163) [classes/:na] 
at Main.main(Main.java:9) [classes/:na] 
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact ouTest:projectTest:pom:1.0 in central (https://repo.maven.apache.org/maven2) 
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39) ~[aether-connector-basic-1.0.0.v20140518.jar:na] 
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355) ~[aether-connector-basic-1.0.0.v20140518.jar:na] 
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67) ~[aether-util-1.0.0.v20140518.jar:na] 
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581) ~[aether-connector-basic-1.0.0.v20140518.jar:na] 
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249) ~[aether-connector-basic-1.0.0.v20140518.jar:na] 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520) ~[aether-impl-1.0.0.v20140518.jar:na] 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421) ~[aether-impl-1.0.0.v20140518.jar:na] 
... 16 common frames omitted 
Exception in thread "main" java.lang.RuntimeException: Cannot find KieModule: ouTest:projectTest: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 controller.DecisionServerTest.test2(DecisionServerTest.java:163) 
at Main.main(Main.java:9) 
+0

您是否在您的maven設置中添加了'http:// kiewbserver:8080/kie-drools-wb/maven2'? –

+0

等待您使用'newUrlResource',嘗試使用「LATEST」作爲版本 –

+0

否我沒有,但我不知道如何。我在Users/user1/.m2 /下創建了一個settings.xml,但我不知道內容的外觀如何,或者目錄是否正確。我想我首先必須閱讀更多關於maven的... – Marv174

回答

1

我想你企圖從下載工作臺乃紀伊罐子,力圖打造罐子在Maven和使用您的project.In內部的情況下,首先按下面的鏈接運行此命令, http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html 然後在yor項目pom文件中添加jar依賴項。 你可以使用下面的代碼來執行應用程序。在執行過程中,你需要很多的jar包。kie-ci,kie-internal是主要的jar包。

  KieServices kieServices = KieServices.Factory.get(); 

      ReleaseId releaseId = kieServices.newReleaseId("org.test", 
        "kie-project-simple", "1.0"); 

      KieContainer kContainer = kieServices.newKieContainer(releaseId); 

      kScanner = kieServices.newKieScanner(kContainer); 

      System.out.println("This is a Kie-Ci example. The drl rule is packaged " + 
        "as a kmodule in a jar and deployed in your maven repo"); 

      // Scan to discover new resources of an existing artifact 
      kScanner.scanNow(); 

      for (int i = 0; i < 100; i++) { 
       // Create a stateless session 
       kSession = kContainer.newKieSession(); 
       kSession.insert("Hello"); 
       kSession.fireAllRules(); 
       try { 
        Thread.sleep(5000); 
       } catch (InterruptedException e) { 
        System.out.println("Thread interrupted. Firing of rules will stop."); 
       } 
      }