5 Replies Latest reply on Mar 15, 2018 6:16 AM by Beena Patil

    Java Rest API for JBPM 7

    yellapu sony Newbie

      Hello All,

       

      I am trying to execute the workflows of JBPM 7.0.0 Final  using java rest API( through  kie-remote client  ).Below is the piece of code i used :

       

      import org.kie.api.runtime.KieSession;

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

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

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

      import org.kie.remote.client.api.RemoteRuntimeEngineFactory;

       

      RuntimeEngine engine =

      RemoteRuntimeEngineFactory.newRestBuilder().addUrl(new URL("http://192.168.175.161:8080/jbpm-console")).addUserName("admin").addPassword("admin").addDeploymentId("ScriptTaskProject_1.0.0").addTimeout(0).build();

      KieSession ksession = engine.getKieSession();

        ProcessInstance processInstance=ksession.startProcess("ScriptTaskProject.ScriptTaskProcess");

      System.out.println("***** Process instance:"+processInstance.getId());

      In the above java code,I used kie-remote-client-6.5.0.Final jar. It works fine till JBPM 6.5.0 Final, but giving below nullpointer exception when trying to execute workflow in jbpm7.0.0 final

       

      Below is the stack trace :

      org.kie.remote.client.api.exception.RemoteCommunicationException: Unable to retrieve content from response!

        at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeRestCommand(AbstractRemoteCommandObject.java:427)

        at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeCommand(AbstractRemoteCommandObject.java:128)

        at org.kie.services.client.api.command.KieSessionClientCommandObject.getFactCount(KieSessionClientCommandObject.java:241)

        at SampleWorkFlowTrigger.main(SampleWorkFlowTrigger.java:37)

      Caused by: java.lang.NullPointerException

        at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeRestCommand(AbstractRemoteCommandObject.java:410)

        ... 3 more

       

      Am i doing anything wrong or is there any new way of using java rest API in JBPM 7.0.0 final ?

       

      Thanks in advance !!.

        • 1. Re: Java Rest API for JBPM 7
          Ripin Yan Newbie

          hi,in the jbpm7, jbpm-console no longer provide task/process.. rest api,it transfer to kie-server: http://localhost:8080/kie-server/docs/

          1 of 1 people found this helpful
          • 2. Re: Java Rest API for JBPM 7
            Beena Patil Newbie

            Hi Ripin

             

            Incase we are starting the jbpm process from remote application, should we still use the RemoteRuntimeEngineFactory.newRestBuilder() and provide the url http://localhost:8080/kie-server/....  I am getting this error while starting the runtime ...

            "HTTP method POST is not supported by this URL:"

             

            RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder()

            .addUrl(new URL("http://localhost:8080/kie-server"))

            .addUserName("admin").addPassword("admin")

            .addDeploymentId("com.myteam:HelloTest:1.0.0")

            .build();

            KieSession ksession = engine.getKieSession();

             

            Can you please let me know which method to call for starting the process, as i am facing the same problem stated above

             

             

            Thanks

            Beena

            • 3. Re: Java Rest API for JBPM 7
              RAFAEL PINO Newbie

              Greetings Beena.

               

              Have you been able to start a process in JBPM 7 successfully?. Please, can you share your solution?.

               

              Thanks.

              • 4. Re: Java Rest API for JBPM 7
                William Siqueira Newbie

                Hi,

                 

                The BC API is deprecated! Use the KIE Server APIs instead. See this to get started:

                 

                https://docs.jboss.org/drools/release/6.4.0.CR2/drools-docs/html/ch22.html#d0e23626jBPM Documentation

                • 5. Re: Java Rest API for JBPM 7
                  Beena Patil Newbie

                  Hi Rafael

                   

                  I used the following to start the process

                   

                      // jBPM Process and Project constants

                      private final String DEPLOYMENT_ID = "com.los:remoteAPITest:1.0";

                      private final String USERNAME = "krisv";

                      private final String PASSWORD = "krisv";

                      private final String CONTAINER_ID = "remoteAPITest_1.0";

                      private final String PROCESS_ID = "remoteAPITest.remoteAPIprocess";

                      private final String SERVER_URL = "http://localhost:8080/kie-server/services/rest/server";

                   

                   

                          KieServicesConfiguration config =  KieServicesFactory.newRestConfiguration(

                              SERVER_URL, USERNAME, PASSWORD);

                          KieServicesClient client = KieServicesFactory.newKieServicesClient(config);

                          ProcessServicesClient processServices = client.getServicesClient(ProcessServicesClient.class);

                          UserTaskServicesClient taskServices = client.getServicesClient(UserTaskServicesClient.class);

                   

                          // start a new process instance

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

                          Long processInstanceId = processServices.startProcess(CONTAINER_ID,PROCESS_ID);//container_id,process_id

                          //Long processInstanceId = processServices.startProcess("evaluation_1.0.0-SNAPSHOT", "evaluation", params);

                          System.out.println("Start Evaluation process " + processInstanceId);

                   

                  Imports in pom.xml

                  <dependency>

                              <groupId>org.kie</groupId>

                              <artifactId>kie-api</artifactId>

                              <version>7.0.0.Final</version>

                          </dependency>

                          <dependency>

                              <groupId>org.kie.server</groupId>

                              <artifactId>kie-server-client</artifactId>

                              <version>7.3.0.Final</version>

                          </dependency>

                  2 of 2 people found this helpful