I decided to change the default serialization format in Camunda from Java to JSON.This gives me better readability of variable values in Camunda Cockpit and I hope to avoid Java class version issues when changing main Java versions.
The JSON support is provided by the Camunda Spin extension. To avoid Jackson/Json-path incompatibility issues (like e.g. #7 Update json-path to 2.0.0) I decided to use the camunda-spin-dataformat-all
dependency which wraps the necessary Jackson code.
Unfortunately I noticed that the Jackson implementation provided by the camunda-spin-dataformat-all library does not support Jackson annotations like @JsonCreator or @JsonProperty. Thus I am not able to deserialize immutable PoJos which have no setter but only a full value constructor.
@JsonCreator
public ImmutablePerson(@JsonProperty("firstName") final String firstName,
@JsonProperty("lastName") final String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
The attempt to deserialize these kind of objects result in the error
can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
I provided a full reproducable test in my camunda-spin-demo project (tag missing-jackson-annotation-support). Just run the ProcessEngineSerializationFormatTest to reproduce the error.
I am not sure how to get over this problem. I probably should use the camunda-spin-dataformat-json-jackson artifact, but then I run into other issues (like #7 - Update json-path to 2.0.0).
It even would be no help to add the Jackson annotations to the camunda-spin-dataformat-all artifact because in my project the PoJo classes come from a separated (PoJo) artifact and the Jackson annotations are used with their original package declaration (and without the spinjar package prefix).
I would love to keep my PoJo immutable and therefore need to use the Jackson annotations but this fails with Camunda.
Any idea how to get over this problem is highly appreciated!