jBPM 6 NoSuchMethodError when calling process instance remotely
aha001 Aug 4, 2014 9:34 PMI am trying to call the process instance remotely, copy the code from Chapter 17. Remote API section
17.1.1.1. Example usage
When I ran the code, I got java.lang.NoSuchMethodError: org.apache.http.auth.AuthState.update(Lorg/apache/http/auth/AuthScheme;Lorg/apache/http/auth/Credentials;)V exception.
If I include all the runtime jar from jbpm-install then it works just fine.
Can somebody please help and advise if I miss out anything?
Dependency put in the pom file.
<dependency>
<groupId>org.kie.remote</groupId>
<artifactId>kie-services-client</artifactId>
<version>6.1.0.CR1</version>
</dependency>
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.api.task.TaskService;
import org.kie.api.task.model.TaskSummary;
import org.kie.services.client.api.RemoteRestRuntimeFactory;
import org.kie.services.client.api.RemoteRuntimeEngineFactory;
import org.kie.services.client.api.command.RemoteRuntimeEngine;
public class Main {
public static void main(String[] args) throws MalformedURLException {
URL instanceUrl = new URL("http://localhost:8080/jbpm-console");
String deploymentId = "com.sample:test:1.0";
String user = "krisv";
String password = "krisv";
RemoteRuntimeEngineFactory restSessionFactory = new RemoteRestRuntimeFactory(
deploymentId, instanceUrl, user, password);
RemoteRuntimeEngine engine = restSessionFactory.newRuntimeEngine();
KieSession ksession = engine.getKieSession();
TaskService taskService = engine.getTaskService();
Map<String, Object> params = new HashMap<String, Object>();
params.put("customerId", "1234");
ProcessInstance processInstance = ksession.startProcess("test.testRemoteCall", params);
long procId = processInstance.getId();
String taskUserId = user;
taskService = engine.getTaskService();
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(user, "en-UK");
long taskId = -1;
for (TaskSummary task : tasks) {
if (task.getProcessInstanceId() == procId) {
taskId = task.getId();
}
}
if (taskId == -1) {
throw new IllegalStateException("Unable to find task for " + user
+ " in process instance " + procId);
}
taskService.start(taskId, taskUserId);
}
}
Got this exception.
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.auth.AuthState.update(Lorg/apache/http/auth/AuthScheme;Lorg/apache/http/auth/Credentials;)V
at org.kie.services.client.api.command.RemoteConfiguration$PreemptiveAuth.process(RemoteConfiguration.java:457)
at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:108)
at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:174)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:462)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.execute(ApacheHttpClient4Executor.java:182)
at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:39)
at org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:40)
at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45)
at org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:444)
at org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:688)
at org.jboss.resteasy.client.ClientRequest.post(ClientRequest.java:572)
at org.jboss.resteasy.client.ClientRequest.post(ClientRequest.java:577)
at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeRestCommand(AbstractRemoteCommandObject.java:398)
at org.kie.services.client.api.command.AbstractRemoteCommandObject.execute(AbstractRemoteCommandObject.java:120)
at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:230)
at nz.co.yellow.flossy.kiwi.v1.Main.main(Main.java:55)