External Task Java Client

Hi,
i have tried to implement an external java Worker as shown in the tutorial : https://docs.camunda.org/get-started/quick-start/service-task/
i have done everything exactly as instructed but i still get the following error messages.
someone knows what’s wrong here?

** 4185 [main] INFO org.camunda.bpm.client - TASK/CLIENT-01026 Discovered data format provider: org.camunda.bpm.client.variable.impl.format.json.JacksonJsonDataFormatProvider[name = application/json]*
** 4188 [main] INFO org.camunda.bpm.client - TASK/CLIENT-01025 Discovered data format: org.camunda.bpm.client.variable.impl.format.json.JacksonJsonDataFormat[name = application/json]*
** 4188 [main] INFO org.camunda.bpm.client - TASK/CLIENT-01026 Discovered data format provider: org.camunda.bpm.client.variable.impl.format.serializable.SerializableDataFormatProvider[name = application/x-java-serialized-object]*
** 4189 [main] INFO org.camunda.bpm.client - TASK/CLIENT-01025 Discovered data format: org.camunda.bpm.client.variable.impl.format.serializable.SerializableDataFormat[name = application/x-java-serialized-object]*
** 4189 [main] INFO org.camunda.bpm.client - TASK/CLIENT-01026 Discovered data format provider: org.camunda.bpm.client.variable.impl.format.xml.DomXmlDataFormatProvider[name = application/xml]*
** 4198 [main] INFO org.camunda.bpm.client - TASK/CLIENT-01025 Discovered data format: org.camunda.bpm.client.variable.impl.format.xml.DomXmlDataFormat[name = application/xml]*
** 4455 [TopicSubscriptionManager] ERROR org.camunda.bpm.client - TASK/CLIENT-03001 Exception while fetch and lock task.*
** org.camunda.bpm.client.impl.EngineClientException: TASK/CLIENT-02005 Exception while mapping json object to response dto class ‘class [Lorg.camunda.bpm.client.task.impl.ExternalTaskImpl;’*
** at org.camunda.bpm.client.impl.EngineClientLogger.exceptionWhileMappingJsonObject(EngineClientLogger.java:51)*
** at org.camunda.bpm.client.impl.RequestExecutor.deserializeResponse(RequestExecutor.java:164)*
** at org.camunda.bpm.client.impl.RequestExecutor$1.handleEntity(RequestExecutor.java:121)*
** at org.camunda.bpm.client.impl.RequestExecutor$1.handleResponse(RequestExecutor.java:152)*
** at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)*
** at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)*
** at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)*
** at org.camunda.bpm.client.impl.RequestExecutor.executeRequest(RequestExecutor.java:88)*
** at org.camunda.bpm.client.impl.RequestExecutor.postRequest(RequestExecutor.java:74)*
** at org.camunda.bpm.client.impl.EngineClient.fetchAndLock(EngineClient.java:78)*
** at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.fetchAndLock(TopicSubscriptionManager.java:135)*
** at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.acquire(TopicSubscriptionManager.java:101)*
** at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.run(TopicSubscriptionManager.java:87)*
** at java.lang.Thread.run(Unknown Source)*
** Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.util.Date from String “2020-02-06”: not a valid representation (error: Failed to parse Date value ‘2020-02-06’: Unparseable date: “2020-02-06”)*
** at [Source: (org.apache.http.conn.EofSensorInputStream); line: 1, column: 262] (through reference chain: java.lang.Object[][0]->org.camunda.bpm.client.task.impl.ExternalTaskImpl[“lockExpirationTime”])*
** at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67)*
** at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1676)*
** at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:932)*
** at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDate(StdDeserializer.java:550)*
** at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDate(StdDeserializer.java:491)*
** at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateBasedDeserializer._parseDate(DateDeserializers.java:195)*
** at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateDeserializer.deserialize(DateDeserializers.java:285)*
** at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateDeserializer.deserialize(DateDeserializers.java:268)*
** at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)*
** at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)*
** at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)*
** at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:195)*
** at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:21)*
** at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202)*
** at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3242)*
** at org.camunda.bpm.client.impl.RequestExecutor.deserializeResponse(RequestExecutor.java:160)*
** … 12 more*

My first guess would be that the client cannot parse this date. Is this value under your control?

I don’t know where the date comes from

Then it could be a version conflict. Which Camunda and task worker versions are you using?

i use the camunda version “camunda-bpm-tomcat-7.11.0”
and the worker version is “1.3.0”

          <dependency>
			<groupId>org.camunda.bpm</groupId>
			<artifactId>camunda-external-task-client</artifactId>
			<version>1.3.0</version>
		</dependency>

Adrian, I followed the referenced instructions to configure the task client. This client (v1.3.0) worked as expected against my Spring boot Camunda server on 7.12 and 7.11. Will also try the pre-built tomcat deployment. I am using Java 11, and you?

On my environment the task worker also works well against the server
https://camunda.org/release/camunda-bpm/tomcat/7.11/camunda-bpm-tomcat-7.11.0.zip

Is you client surely identical? Java version?

package org.camunda.bpm.getstarted.chargecard;

import java.util.logging.Logger;
import org.camunda.bpm.client.ExternalTaskClient;

public class ChargeCardWorker {
    private final static Logger LOGGER = Logger.getLogger(ChargeCardWorker.class.getName());

    public static void main(String[] args) {
        ExternalTaskClient client = ExternalTaskClient.create()
                .baseUrl("http://localhost:8080/engine-rest")
                .asyncResponseTimeout(10000) // long polling timeout
                .build();

        // subscribe to an external task topic as specified in the process
        client.subscribe("charge-card")
                .lockDuration(1000) // the default lock duration is 20 seconds, but you can override this
                .handler((externalTask, externalTaskService) -> {
                    // Put your business logic here

                    // Get a process variable
                    String item = (String) externalTask.getVariable("item");
                    Long amount = (Long) externalTask.getVariable("amount");
                    LOGGER.info("Charging credit card with an amount of '" + amount + "'€ for the item '" + item + "'...");

                    // Complete the task
                    externalTaskService.complete(externalTask);
                })
                .open();
    }
}

Im using the pre-built tomcat server. It looks like its the version. I changed the version from 7.11.0 to 7.12 and it works now.

Thank you that helps me a lot :slight_smile:

1 Like

Hi @Adrian,

happy that you resolved the issue :slight_smile:
If you have a look at the version compatibility matrix of the external task client, you can see that 1.3.0 (client) is bound to 7.12 (engine). This is important since the client relies on the engine rest API.

Cheers,
Miklas

1 Like