Engine Rest Client - NoSuchMethodError

Hello Everyone,

I’m trying to integrate my application with the camunda engine via rest client using this guy. When I try to start camunda process with the given id and businessKey I get the following error:

Caused by: java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
	at org.camunda.community.rest.client.invoker.ApiClient.serialize(ApiClient.java:816)
	at org.camunda.community.rest.client.invoker.ApiClient.buildRequest(ApiClient.java:1069)
	at org.camunda.community.rest.client.invoker.ApiClient.buildCall(ApiClient.java:1018)
	at org.camunda.community.rest.client.api.ProcessDefinitionApi.startProcessInstanceByKeyCall(ProcessDefinitionApi.java:4995)
	at org.camunda.community.rest.client.api.ProcessDefinitionApi.startProcessInstanceByKeyValidateBeforeCall(ProcessDefinitionApi.java:5007)
	at org.camunda.community.rest.client.api.ProcessDefinitionApi.startProcessInstanceByKeyWithHttpInfo(ProcessDefinitionApi.java:5048)
	at org.camunda.community.rest.client.api.ProcessDefinitionApi.startProcessInstanceByKey(ProcessDefinitionApi.java:5028)

An here is the code where I use rest api client:

@Service
@Transactional
@RequiredArgsConstructor
public class CamundaIssueService {
    
    private final ProcessDefinitionApi processDefinitionApi;
    
    public void startProcess() throws ApiException {
        processDefinitionApi.startProcessInstanceByKey(
            START_ISSUE_KEY,
            new StartProcessInstanceDto().businessKey("1")
        );
    }
}

When i try to do the same with the POSTMAN call to http://localhost:8080/engine-rest/process-definition/myProcessKey/start, then everything works perfectly fine.
Does anyone knows what’s wrong?

Adam

Hello @olszewskia ,

this looks like the client has a problem.

You could debug this to find the missing method.

I hope this helps

Jonathan

1 Like

Hello @jonathan.lukas

Thanks for your quick reply. Missing method is already shown in attached logs, which is okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType).

Not much I can do since this method is used in Camunda Engine REST Client Complete SpringBoot Starter which is camunda rest client not mine. I only use ProcessDefinitionApi to call the API.

Adam

Hello @olszewskia ,

have you checked whether you have dependency problems, for example by pulling multiple versions of the same artifact?

Jonathan

1 Like

@olszewskia Should be like

RequestBody.create(requestString.getBytes(),
				MediaType.parse("application/json; charset=utf-8"))

I was using this version and works fine:

<dependency>
	<groupId>com.squareup.okhttp3</groupId>
	<artifactId>okhttp</artifactId>
	<version>4.9.2</version>
</dependency>
2 Likes

Hello @jonathan.lukas and @aravindhrs

Thanks for your reply!
Here is my dependency tree for camunda rest client.

It looks like com.squareup.okhttp3:okhttp:4.9.2 is now added but camunda engine rest client is still using version 3.14.9.
IntelliJ complains too


and error still exists.

Adam

Hello @olszewskia ,

I would suggest to use dependencyManagement to make use of only 1 version.

And please file a big report.

Jonathan

1 Like

Thank you @jonathan.lukas and @aravindhrs for your effort.

The problem lies on the wrong version of the com.squareup.okhttp3:okhttp and like @jonathan.lukas
suggested, one have to add proper version to the dependencyManagement in the root pom.xml file

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>4.9.2</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

Thus, it solved the problem.

Adam

1 Like