# Hi Deserialization problem

**URL:** <https://community.temporal.io/t/hi-deserialization-problem/474>\
**Category:** Community Support\
**Tags:** java-sdk, kotlin\
**Created:** [August 17, 2020, 3:32pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474 "2020-08-17T15:32:06Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![shawel\_negussie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shawel_negussie/32/231_2.png) [@shawel\_negussie](https://community.temporal.io/u/shawel_negussie)\
**Post date:** [August 17, 2020, 3:32pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/1 "2020-08-17T15:32:06Z")

</div>

Hi,  
I am using using [temporal.io](http://temporal.io) Java SDK with Kotlin. I switched from cadence to Temporal which required me to upgrade Jackson. After upgrade I am noticing deserialization errors with classes. I had to add dummy constructors with data classes. Is there a place where data serialization libraries are set.

Errors looks something like this  
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.google.protobuf.UnknownFieldSet$Parser and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL\_ON\_EMPTY\_BEANS)

Best

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 18, 2020, 4:00am UTC](https://community.temporal.io/t/hi-deserialization-problem/474/3 "2020-08-18T04:00:48Z")

</div>

Switchin to Jackson was very common feature request as gson wasn’t actively developed.

I would recommend checking Jackson documentation for possible solutions.

If you want to change properties of Jackson serializer or even switch back to the gson one see the [converter](https://github.com/temporalio/java-sdk/blob/19c701df8d75040d87db4aea1fd38876bb33b3a8/src/main/java/io/temporal/common/converter/DefaultDataConverter.java#L42) package.

---

<div class="post-metadata">

**Author:** ![shyamal](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shyamal/32/119_2.png) [@shyamal](https://community.temporal.io/u/shyamal)\
**Post date:** [August 18, 2020, 3:39pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/4 "2020-08-18T15:39:27Z")

</div>

The current java-sdk API makes this a tad brittle, but the approach works for me:

```auto
    val mapper = ObjectMapper()

    // Configure the mapper just like the JacksonJsonPayloadConverter() constructor would
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
    mapper.registerModule(JavaTimeModule())
    mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)

    // Now add Kotlin support
    mapper.registerModule(KotlinModule())

    // And build the exact same thing as DefaultDataConverter::defaultDataConverterInstance
    val converter = new DefaultDataConverter(
            NullPayloadConverter(),
            ByteArrayPayloadConverter(),
            ProtobufJsonPayloadConverter(),
            JacksonJsonPayloadConverter(mapper))

    // Now create a workflow client options with it, and move along as before!
    val workflowClientOptions = WorkflowClientOptions.newBuilder()
                .setDataConverter(converter)
                .build();

```

---

<div class="post-metadata">

**Author:** ![shawel\_negussie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shawel_negussie/32/231_2.png) [@shawel\_negussie](https://community.temporal.io/u/shawel_negussie)\
**Post date:** [August 18, 2020, 4:15pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/5 "2020-08-18T16:15:51Z")

</div>

Thank you @maxim and @shyamal.

I got it mostly working mainly forcing it to use similar to the one you have @shyamal.

It works great as long as I call the workflow function directly. The sticking point is the exception when I use

> WorkflowClient.start(singerWorkflowImpl::singerWorkflow, singerConfig)

I am getting the following exceptio

“No serializer found for class com.google.protobuf.UnknownFieldSet$Parser and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL\_ON\_EMPTY\_BEANS) (through reference chain: io.temporal.api.common.v1.WorkflowExecution["unknownFields"]-\>com.google.protobuf.UnknownFieldSet["parserForType"])”

Here is my workflow start code that i try to force using GsonJsonPayloadConverter() same error

> val workflowOptions = WorkflowOptions.newBuilder()  
> .setWorkflowExecutionTimeout(Duration.ofDays(10000))  
> .setTaskQueue(“singer-activity-task-list”)  
> .setWorkflowIdReusePolicy(WorkflowIdReusePolicy.WORKFLOW\_ID\_REUSE\_POLICY\_ALLOW\_DUPLICATE)  
> .setWorkflowId(id)  
> .build()
> 
> ```
> val service = WorkflowServiceStubs.newInstance();
> 
> val wfc: WorkflowClient = WorkflowClient.newInstance(service,
> WorkflowClientOptions.newBuilder()
> .setDataConverter(DefaultDataConverter(GsonJsonPayloadConverter()))
> .setNamespace("singer-activity-namespace")
> .build())
> 
> ```

Do you have any idea what that exception is or what it is trying to do?

Best

---

<div class="post-metadata">

**Author:** ![shyamal](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shyamal/32/119_2.png) [@shyamal](https://community.temporal.io/u/shyamal)\
**Post date:** [August 18, 2020, 4:47pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/6 "2020-08-18T16:47:52Z")

</div>

My best guess is you only provided the Gson payload converter. Try adding the three other non-JSON payload converters first, and then your `GsonJsonPayloadConverter` when you build the `DefaultDataConverter`?

I’m a newbie at this stuff, but it is odd that you’re seeing a Jackson error, so I’m only guessing at this point. In my experience changing the SDK serialization strategy is best done very gently (do as little of it as you can).

Is there a reason you cannot use the default Jackson strategy, and just configure it with the KotlinModule (like in my code snippet)? Does that not work for you? Without the KotlinModule you _will surely_ get deserialization errors for plain Kotlin classes.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 18, 2020, 4:57pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/7 "2020-08-18T16:57:21Z")

</div>

You disabled all other converters and kept only Gson one. And it looks like you are trying to pass WorkflowExecution class as a parameter. As WorkflowExecution class is a protobuf the Gson doesn’t know how to serialize it. Make sure to keep Protobuf converter in the list of the converters.

---

<div class="post-metadata">

**Author:** ![shawel\_negussie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shawel_negussie/32/231_2.png) [@shawel\_negussie](https://community.temporal.io/u/shawel_negussie)\
**Post date:** [August 18, 2020, 8:01pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/8 "2020-08-18T20:01:15Z")

</div>

thanks @maxim & @shyamal it works.

@shyamal  
It does work with JacksonJsonPayloadConverter(mapper) as you described it. However it is having trouble handling interfaces. I managed to get it working by adding a custom module with the following code to handle my interfaces

```
    private val objectMapper: ObjectMapper = ObjectMapper()
    private val resolver = SimpleAbstractTypeResolver()
    .addMapping(SingerActivityCallBackInterface::class.java, SingerController.SingerActivityCallBack::class.java)
    private val module = SimpleModule("CustomModel", Version.unknownVersion())

objectMapper.registerModule(KotlinModule())
                .registerModule(JavaTimeModule())
                .registerModule(module)
                .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
                .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);

```

but i have quite a few interfaces and I did not want to couple the object mapper like this.  
If you know of alternative let me know. GsonJsonPayloadConverter() works just fine for now, but I’d like to use Jackson for sure.

Thank you

---

<div class="post-metadata">

**Author:** ![shawel\_negussie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shawel_negussie/32/231_2.png) [@shawel\_negussie](https://community.temporal.io/u/shawel_negussie)\
**Post date:** [August 18, 2020, 8:20pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/9 "2020-08-18T20:20:26Z")

</div>

One thing I notices is the Params and result of the work flow are not serialized! I have a string return type and I was expecting to see it in the front end. Could this be the same problem? For example

 ![Screen Shot 2020-08-18 at 4.19.34 PM](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/1X/dc21d9ed1d63fca6c6688f45a300e672cd01fd44.png)

result should be a string.

Best

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 19, 2020, 10:44pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/10 "2020-08-19T22:44:55Z")

</div>

Is result empty in the exported history JSON? It might be UI issue.

---

<div class="post-metadata">

**Author:** ![shawel\_negussie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shawel_negussie/32/231_2.png) [@shawel\_negussie](https://community.temporal.io/u/shawel_negussie)\
**Post date:** [August 20, 2020, 1:59pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/11 "2020-08-20T13:59:06Z")

</div>

@maxim

Correct error must be from the front end. The run history from the command line does show result payload there which was what i was expecting

> 10 WorkflowExecutionCompleted {Result:[[Mock Result:  
> 0.891770742597598]],  
> WorkflowTaskCompletedEventId:9}

The JSON from the frontend UI still does not have result. so probably a bug

```auto
"workflowTaskCompletedEventId": "9",
      "eventId": "10",
      "eventType": "WorkflowExecutionCompleted",
      "kvps": [
        {
          "key": "result",
          "value": {
            "jsonStringDisplay": "{\n \"payloads\": []\n}",
            "jsonStringFull": "{\n \"payloads\": []\n}"
          }
        },
        {
          "key": "workflowTaskCompletedEventId",
          "value": "9"
        }

```

Related question! Is there any way to get this result within the workflow. i know if we use cron we can use Workflow.getLastCompletionResult. But i wanted to use periodic loop and wanted to get pervious result.

Thanks for the help

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 20, 2020, 3:34pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/12 "2020-08-20T15:34:14Z")

</div>

What UI/Service version are you using? I believe the latest release fixed a lot of UI related bugs.

If you are doing periodic loop using continue as new then you can pass the data from the previous run as arguments to the next one.

---

<div class="post-metadata">

**Author:** ![shawel\_negussie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shawel_negussie/32/231_2.png) [@shawel\_negussie](https://community.temporal.io/u/shawel_negussie)\
**Post date:** [August 20, 2020, 4:00pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/13 "2020-08-20T16:00:32Z")

</div>

@maxim  
I am using v0.28-web. If there is a new version i will update.

 ![Screen Shot 2020-08-20 at 11.51.19 AM](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/1X/487375c48eb030228a37fade6e78c401e5781aa6.png)

Thanks! You mean something like “pastResult” in this code. Will this be fault tolerant?

> ```
> fun singerWorkflow(singerConfig: SingerConfig): List<String> {
> val pastResult = null
> 
> // for scheduled workflow 
> if (singerConfig.schedule != null) {
> for (i in 0 until Companion.CONTINUE_AS_NEW_FREQUENCY) {
> pastResult = singerActivities.stub(pastResult = pastResult)
> Workflow.sleep(
> Duration.of(singerConfig.schedule.gap,
> ChronoUnit.valueOf(singerConfig.schedule.frequency.toString()))
> )
> }
> 
> singerActivitiesContinue.singerWorkflow(singerConfig)
> }
> // if one off activity
> return singerActivities.stub()
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 20, 2020, 5:33pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/14 "2020-08-20T17:33:59Z")

</div>

I meant passing this data as an argument to the continue as new:

```auto
fun singerWorkflow(singerConfig: SingerConfig, pastResult: List<String>): List<String> {
    // for scheduled workflow 
    if (singerConfig.schedule != null) {
        for (i in 0 until Companion.CONTINUE_AS_NEW_FREQUENCY) {
            pastResult = singerActivities.stub(pastResult = pastResult)
            Workflow.sleep(
                    Duration.of(singerConfig.schedule.gap,
                            ChronoUnit.valueOf(singerConfig.schedule.frequency.toString()))
            )
        }

        singerActivitiesContinue.singerWorkflow(singerConfig, pastResult)
    }
    // if one off activity
    return singerActivities.stub()
}

```

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [August 20, 2020, 5:38pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/15 "2020-08-20T17:38:27Z")

</div>

Just a correction, there is a newer version 0.28.1 which has the fix for Payloads on Web UI

---

<div class="post-metadata">

**Author:** ![shawel\_negussie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shawel_negussie/32/231_2.png) [@shawel\_negussie](https://community.temporal.io/u/shawel_negussie)\
**Post date:** [August 20, 2020, 5:47pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/17 "2020-08-20T17:47:28Z")

</div>

Ok great thank you @maxim did not realize that you could do that.

@Ruslan is there a docker release for it? If not i will just wait to upgrade, since this is on a kubernetes instance

Thank you

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 20, 2020, 5:52pm UTC](https://community.temporal.io/t/hi-deserialization-problem/474/18 "2020-08-20T17:52:11Z")

</div>

Yes, [there is](https://github.com/temporalio/temporal/blob/2e1159f9f252ccabd5a316261638b39ca35737dd/docker/docker-compose.yml#L27) a docker release for 28.1.

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [August 27, 2020, 1:00am UTC](https://community.temporal.io/t/hi-deserialization-problem/474/21 "2020-08-27T01:00:04Z")

</div>

This topic was automatically closed after 31 hours. New replies are no longer allowed.
