There are couple of threads that I can see on this serializer problem and no conclusion force me to ask the below question . Hope I will get some help to clear my doubts.
I am using JDK 1.8 Camunda 7.11.X
I have a simple POJO which is getting populated by a rest service and I am setting the pojo in the camunda to kick start a process
I can see it is giving error about no serializer which is quite fare. When I see the camuda document I use the below syntax to provide a serializer but then also it is giving the exception as “Cannot find serializer for value 'ObjectValue”
"When an object value is passed to the process engine, a serialization format can be specified to tell the process engine to store the value in a specific format. Based on this format, the engine looks up a serializer . The serializer is able to serialize a Java object to the specified format and deserialize it from a representation in that format. That means, there may be different serializers for different formats and it is possible to implement custom serializers in order to store custom objects in a specific format.
The process engine ships one built-in object serializer for the format application/x-java-serialized-object . It is able to serialize Java objects that implement the interface java.io.Serializable and applies standard Java object serialization. "
Therefore you are seeing the expected behavior of the engine. In other words the engine needs to know that your Java object is serializable to know how to set and get the object from the engine.
If we mark the object as transient , then also do we need to implement java.io.Serializable interface ? I guess for transient it would behave like as primitive data type as it is not required to store in the database , it is something to keep in JVM memory only ?
Camunda will always serialize your custom object type and by default it will serialize to XML or JSON (whichever serializer is first on your classpath) when you set a variable as a process variable. If you wish to serialize to/from Java then you still need to make sure to mark your Java class as serializable. Additionally, transient custom object types will be serialized to and from the JVM as well even if not stored in the db.
So to answer your question. Yes, you should implement serializable if you want to serialize your object to Java to/from the JVM and serialize the process variable. Otherwise your object will be serialized to XML or JSON by default.
What is the reason to serialize to Java and not use the standard behavior? We recommend serializing to JSON as it makes it easy to read to other applications accessing your db or object.
Here is an image that shows the standard serialization which Camunda uses as well.