# Deserialize org.camunda.bpm.engine.variable.VariableMap

**URL:** <https://forum.camunda.io/t/deserialize-org-camunda-bpm-engine-variable-variablemap/47819>\
**Category:** Camunda 7 Topics\
**Created:** [September 27, 2023, 6:13pm UTC](https://forum.camunda.io/t/deserialize-org-camunda-bpm-engine-variable-variablemap/47819 "2023-09-27T18:13:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![moshell](https://forum.camunda.io/user_avatar/forum.camunda.io/moshell/32/27287_2.png) [@moshell](https://forum.camunda.io/u/moshell)\
**Post date:** [September 27, 2023, 6:13pm UTC](https://forum.camunda.io/t/deserialize-org-camunda-bpm-engine-variable-variablemap/47819/1 "2023-09-27T18:13:22Z")

</div>

Hi all!

In my project i use externalTaskService java api

```auto
List<LockedExternalTask> taskList = camunda.getExternalTaskService()
                    .fetchAndLock(100, EXTERNAL_WORKER_ID)
                    .topic(topic, 1L)
                    .execute();

ExternalTaskDataDto dto = ExternalTaskDataDto.builder()
                        .taskId(lockedExternalTask.getId())
                        .processDefinitionId(lockedExternalTask.getProcessDefinitionId())
                        .processInstanceId(lockedExternalTask.getProcessInstanceId())
                        .activityId(lockedExternalTask.getActivityId())
                        .activityInstanceId(lockedExternalTask.getActivityInstanceId())
                        .variables(lockedExternalTask.getVariables())
                        .build();

```

then ExternalTaskDataDto send to apache kafka topic, which is used by opposite side

on remote side i want to receive the message from kafka and handle it.

but, i have an error message about deserialize

`2023-09-27 21:03:01.204 ERROR 69701 --- [container-0-C-1] o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder$1@15256482]; nested exception is java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a deserializer for non-concrete Map type [map type; class org.camunda.bpm.engine.variable.VariableMap, [simple type, class java.lang.String] -> [simple type, class java.lang.Object]]`

on serviceA I use the following starter

```auto
		<dependency>
			<groupId>org.camunda.community.rest</groupId>
			<artifactId>camunda-platform-7-rest-client-spring-boot-starter</artifactId>
			<version>7.19.0</version>
		</dependency>

```

so i can use VariableMap class from camunda.

Help please, how to deserialize VariableMap?  
Thanks for any ideas.

ps. i hope you understand me, sorry for my english 🙂

---

<div class="post-metadata">

**Author:** ![WilliamR.Alves](https://forum.camunda.io/user_avatar/forum.camunda.io/williamr.alves/32/27412_2.png) [@WilliamR.Alves](https://forum.camunda.io/u/WilliamR.Alves)\
**Post date:** [September 27, 2023, 6:37pm UTC](https://forum.camunda.io/t/deserialize-org-camunda-bpm-engine-variable-variablemap/47819/2 "2023-09-27T18:37:38Z")

</div>

Hello my friend!

Do you have any default (empty) constructors in your `ExternalTaskDataDto` class?

I ask this because Jackson uses reflection “under the hood”, instantiating the class without passing parameters, and only after this does Jackson fill in the attributes through reflection.

So if you don’t declare a constructor, Java itself creates a default, but as we are talking about a DTO, you must have declared a constructor that receives the entity as a parameter, so you must declare another constructor without arguments so that Jackson can work correctly.

I hope this is it and that I was able to help you.

**William Robert Alves**

---

<div class="post-metadata">

**Author:** ![moshell](https://forum.camunda.io/user_avatar/forum.camunda.io/moshell/32/27287_2.png) [@moshell](https://forum.camunda.io/u/moshell)\
**Post date:** [September 27, 2023, 6:41pm UTC](https://forum.camunda.io/t/deserialize-org-camunda-bpm-engine-variable-variablemap/47819/3 "2023-09-27T18:41:44Z")

</div>

Hello!

Yes, there is a default constructor

```auto
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor(access = PRIVATE)
public class ExternalTaskDataDto {
    private String taskId;
    private String processDefinitionId;
    private String processInstanceId;
    private String activityId;
    private String activityInstanceId;
    private VariableMap variables;
}

```

---

<div class="post-metadata">

**Author:** ![Adagatiya](https://forum.camunda.io/user_avatar/forum.camunda.io/adagatiya/32/22124_2.png) [@Adagatiya](https://forum.camunda.io/u/Adagatiya)\
**Post date:** [September 27, 2023, 7:08pm UTC](https://forum.camunda.io/t/deserialize-org-camunda-bpm-engine-variable-variablemap/47819/4 "2023-09-27T19:08:26Z")

</div>

Hi @moshell ,

`VariableMap` is an interface and thus cannot be instantiated directly by Jackson without any hints what implementation should be used. Please try to use `VariableMapImpl` instead.

Otherwise, you could use Jackson`default typing mechanism to preserve the typing. See this post on Stackoverflow: [json - How to customize Jackson type information mechanism - Stack Overflow](https://stackoverflow.com/questions/12353774/how-to-customize-jackson-type-information-mechanism).

Kind regards  
Adagatiya

---

<div class="post-metadata">

**Author:** ![moshell](https://forum.camunda.io/user_avatar/forum.camunda.io/moshell/32/27287_2.png) [@moshell](https://forum.camunda.io/u/moshell)\
**Post date:** [September 28, 2023, 12:29pm UTC](https://forum.camunda.io/t/deserialize-org-camunda-bpm-engine-variable-variablemap/47819/5 "2023-09-28T12:29:28Z")

</div>

**Adagatiya** , thank you =)

---

<div class="post-metadata">

**Author:** ![system](https://forum.camunda.io/uploads/default/original/3X/5/8/58d50142eacca605d35cb1ef9e6b86ae85f49436.png) [@system](https://forum.camunda.io/u/system)\
**Post date:** [October 5, 2023, 12:30pm UTC](https://forum.camunda.io/t/deserialize-org-camunda-bpm-engine-variable-variablemap/47819/6 "2023-10-05T12:30:23Z")

</div>

Closed on October 5, 2023, 12:30pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
