1 Reply Latest reply on Oct 16, 2014 8:00 AM by Domenico Schiavone

    Problem with run jar file

    Domenico Schiavone Newbie

      Hi to all,

      i'm new in this forum and i hope that i don't err to make this question in this place.

       

      I created a jbpm project (Maven) with inside any script task that make somethings.

      Now if i run the main class inside the ide eclipse then everything goes well

      but if i export the project in jar file with all libraries and run jar file through the shell then i receive this problem:

       

      Exception in thread "main" java.lang.RuntimeException: The requested KieBase "kbase" does not exist

          at org.drools.compiler.kie.builder.impl.KieContainerImpl.createKieBase(KieContainerImpl.java:235)

          at org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:204)

          at com.sample.MainPrincipale.main(MainPrincipale.java:26)

       

      Somebody can help me??

       

      the main code is:

       

      package com.sample;

       

      import java.util.HashMap;

      import java.util.Map;

      import javax.persistence.EntityManagerFactory;

      import javax.persistence.Persistence;

      import org.jbpm.test.JBPMHelper;

      import org.kie.api.KieBase;

      import org.kie.api.KieServices;

      import org.kie.api.runtime.KieContainer;

      import org.kie.api.runtime.KieSession;

      import org.kie.api.runtime.manager.RuntimeEngine;

      import org.kie.api.runtime.manager.RuntimeEnvironmentBuilder;

      import org.kie.api.runtime.manager.RuntimeManager;

      import org.kie.api.runtime.manager.RuntimeManagerFactory;

       

       

      public class MainPrincipale {

       

          public static void main(String[] args) {

              KieServices ks = KieServices.Factory.get();

              KieContainer kContainer = ks.getKieClasspathContainer();

              KieBase kbase = kContainer.getKieBase("kbase");

       

              RuntimeManager manager = createRuntimeManager(kbase);

              RuntimeEngine engine = manager.getRuntimeEngine(null);

              KieSession ksession = engine.getKieSession();       

             

              //Settaggio dei parametri

              Map<String, Object> para = new HashMap<String, Object>();

              HTTPClient clienth = new HTTPClient();       

              para.put("clienth", clienth);

              ksession.startProcess("com.sample.bpmn.http",para);

              ////////////////////////////////////////////////////////////////////////////////////////       

       

              manager.disposeRuntimeEngine(engine);

              System.exit(0);

          }

       

          private static RuntimeManager createRuntimeManager(KieBase kbase) {

              JBPMHelper.startH2Server();

              JBPMHelper.setupDataSource();

              EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");

              RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.Factory.get()

                  .newDefaultBuilder().entityManagerFactory(emf)

                  .knowledgeBase(kbase);

              return RuntimeManagerFactory.Factory.get()

                  .newSingletonRuntimeManager(builder.get(), "com.sample:example:1.0");

          }

       

      }