2 Replies Latest reply on Sep 10, 2014 9:39 AM by Maria Grazia Morciano

    Remote Rest Api

    chaan King Newbie

      @

      Hi everybody,

       

      I'm trying to execute the Evaluation example with the remote rest api (deploying jbpm 6.0).

      When i'm using the jbpm console to create new instance of this wf, it's works fine. I view each task for each use (krisv, john, mary) in the good order.

      But when i'm using a main program to execute this a get some exception

       

      Here is my code

       

      import java.net.MalformedURLException;

      import java.net.URL;

      import java.util.Collection;

       

       

      import org.kie.api.runtime.KieSession;

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

      import org.kie.api.runtime.process.ProcessInstance;

      import org.kie.api.task.TaskService;

      import org.kie.services.client.api.RemoteRestRuntimeFactory;

       

       

      /**

      * This is a sample test of the evaluation process.

      */

       

       

      public class RestTest {

       

       

        public static void main(String[] args) throws MalformedURLException

        {

        String deploymentId = "org.jbpm:Evaluation:1.0";

         URL appUrl = new URL("http://localhost:8080/jbpm-console/");

         String user = "admin";

         String password = "admin";

        

        

         RemoteRestRuntimeFactory restSessionFactory = new RemoteRestRuntimeFactory(

         deploymentId, appUrl, user, password);

         RuntimeEngine engine = restSessionFactory.newRuntimeEngine();

        

        

         KieSession ksession = engine.getKieSession();

         TaskService taskService = engine.getTaskService();

         ProcessInstance processInstance1 = ksession.getProcessInstance(1);

         System.err.println("MyRestEngine.processName: "

         + processInstance1.getProcessName());

        

        

         Collection<ProcessInstance> processInstances = ksession

         .getProcessInstances();

        

        

         System.err.println("MyRestEngine.processInstances.size: "

         + processInstances.size());

         for (ProcessInstance processInstance : processInstances) {

         System.err.println("MyRestEngine.processInstanceName: "

         + processInstance.getProcessName());

         }

        }

      }

       

      +++++++++++++++++++++++++++++++++++Console+++++++++++++++++++++++++++

       

      Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/protocol/HttpContext

        at org.kie.services.client.api.RemoteRestRuntimeFactory.<init>(RemoteRestRuntimeFactory.java:13)

        at RestTest.main(RestTest.java:28)

      Caused by: java.lang.ClassNotFoundException: org.apache.http.protocol.HttpContext

        at java.net.URLClassLoader$1.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(Unknown Source)

        at java.lang.ClassLoader.loadClass(Unknown Source)

        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

        at java.lang.ClassLoader.loadClass(Unknown Source)

        ... 2 more