# Migration Java to Jackson serialization

**URL:** <https://discuss.akka.io/t/migration-java-to-jackson-serialization/5523>\
**Category:** Akka Libraries\
**Created:** [December 4, 2019, 1:09am UTC](https://discuss.akka.io/t/migration-java-to-jackson-serialization/5523 "2019-12-04T01:09:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![john](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@john](https://discuss.akka.io/u/john)\
**Post date:** [December 4, 2019, 1:09am UTC](https://discuss.akka.io/t/migration-java-to-jackson-serialization/5523/1 "2019-12-04T01:09:32Z")

</div>

Hey.  
My project is using java serializer. I am migrating to akka 2.6

My message classes is used as below with java serializer.  
**public class MyMessage implements Serializable**  
**serializers {**  
\*\* java = “akka.serialization.JavaSerializer”\*\*  
\*\* jackson-json = “akka.serialization.jackson.JacksonJsonSerializer”\*\*  
\*\* }\*\*  
\*\* serialization-bindings {\*\*  
\*\* “com.my.MyMessage” = java\*\*  
\*\* }\*\*

I modified as described.  
([https://doc.akka.io/docs/akka/current/additional/rolling-updates.html#from-java-serialization-to-jackson](https://doc.akka.io/docs/akka/current/additional/rolling-updates.html#from-java-serialization-to-jackson))

**public class MyMessage implements Serializable, MySerializable**  
**serializers {**  
\*\* java = “akka.serialization.JavaSerializer”\*\*  
\*\* jackson-json = “akka.serialization.jackson.JacksonJsonSerializer”\*\*  
\*\* }\*\*  
\*\* serialization-bindings {\*\*  
\*\* “com.my.MyMessage” = java\*\*  
\*\* }\*\*

but, It cannot work. I can’t understand this comment.  
**Change message classes by adding the marker interface and possibly needed annotations as described in [Serialization with Jackson](https://doc.akka.io/docs/akka/current/serialization-jackson.html).**

How can old cluster deserialize java/jackson in 2nd step? Please explain in detail.

---

<div class="post-metadata">

**Author:** ![patriknw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/patriknw/32/89_2.png) [@patriknw](https://discuss.akka.io/u/patriknw)\
**Post date:** [December 5, 2019, 8:06am UTC](https://discuss.akka.io/t/migration-java-to-jackson-serialization/5523/2 "2019-12-05T08:06:35Z")

</div>

> [@john](#):
>
> Change message classes by adding the marker interface

That is what you have done in:

```auto
public class MyMessage implements Serializable, MySerializable

```

The marker interface is `MySerializable`. That is what you will later add to `serialization-bindings` instead of the java binding:

```auto
serialization-bindings {
  "com.my. MySerializable" = jackson-json
}

```

I don’t think you should have `"com.my.MyMessage" = java` in the bindings in the first place because that is already covered by `java.io.Serializable` binding.

> [@john](#):
>
> How can old cluster deserialize java/jackson in 2nd step?

In 2nd step there will be no Jackson serialization/deserialization because `MySerializable` has not been added to the bindings (for serialization/toBinary) yet.

In 3rd step the new cluster nodes will start using Jackson for serialization/toBinary and when those messages are received the old cluster nodes are prepared to deserialize those given the changes in 2nd step.

When writing this I realize that we might have missed one thing in that description. 2nd step might need config:

```auto
akka.serialization.jackson.whitelist-class-prefix = ["com.my.MyMessage"]

```

I’ll test that and let you know if that is also needed.

What error did you see, or what was it that didn’t work?

---

<div class="post-metadata">

**Author:** ![john](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@john](https://discuss.akka.io/u/john)\
**Post date:** [December 5, 2019, 8:44am UTC](https://discuss.akka.io/t/migration-java-to-jackson-serialization/5523/3 "2019-12-05T08:44:47Z")

</div>

Thanks for your kind explanation.  
I missed this like your mention.  
Really appreciate it.

> akka.serialization.jackson.whitelist-class-prefix = [“com.my.MyMessage”]

---

<div class="post-metadata">

**Author:** ![patriknw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/patriknw/32/89_2.png) [@patriknw](https://discuss.akka.io/u/patriknw)\
**Post date:** [December 5, 2019, 1:23pm UTC](https://discuss.akka.io/t/migration-java-to-jackson-serialization/5523/4 "2019-12-05T13:23:44Z")

</div>

I have verified that the `whitelist` is needed and missing in the instructions. Documentation will be updated in next version.

```auto
akka.serialization.jackson.whitelist-class-prefix=["com.myapp"]

```

is needed in step 2. Replace `com.myapp` with the name of the root package of your application to trust all classes. This is needed for Jackson deserialization when the `serialization-bindings` isn’t defined.

The whitelist can be removed in step 3, because then it’s defined in the `serialization-bindings`.

Thanks for reporting.

---

<div class="post-metadata">

**Author:** ![gust](https://avatars.discourse-cdn.com/v4/letter/g/90db22/32.png) [@gust](https://discuss.akka.io/u/gust)\
**Post date:** [May 4, 2022, 7:05am UTC](https://discuss.akka.io/t/migration-java-to-jackson-serialization/5523/5 "2022-05-04T07:05:51Z")

</div>

Hello @patriknw ,  
sorry for digging out such old thread :-)  
[step 2](https://doc.akka.io/docs/akka/current/additional/rolling-updates.html?_ga=2.119400393.1380141761.1651558302-1258006193.1644577931#from-java-serialization-to-jackson) “adding the marker interface” would already break java serialization for case classes which did not yet have the explicit `SerialVersionUID` annotation, right?  
So step 1 should include “add SerialVersionUID to all message classes that are candidates for adding the marker interface in step 2”.  
Correct?
