Missing Jackson annotation support in Camunda Spin

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!

1 Like

Hi Franz,

You simply can’t use camunda-spin-dataformat-all in this case. You should rather try to resolve your other issues with camunda-spin-dataformat-json-jackson.

Cheers,
Thorben

But using dataformat-all was the solution to solve my other issue…

So no easy way out at the moment I guess :frowning:

Hm, indeed. What does Spring IO require json-path for? Maybe you can override that dependency version?

The dependency is obviously only required for testing.

+- org.springframework.boot:spring-boot-starter-test:jar:1.5.3.RELEASE:test
|  +- org.springframework.boot:spring-boot-test:jar:1.5.3.RELEASE:test
|  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.3.RELEASE:test
|  +- com.jayway.jsonpath:json-path:jar:2.2.0:test
| ....

I will try if I can override it without any harm although I rather would not touch these managed dependency versions.

Strange that this issue (still) exists. I would have thought that this should make trouble for many people.

1 Like

Yes, it’s making troubles to me as of now. I have to create a default constructor and the setter methods just because of serialization. :-/