De-Serializing problem for virtual read-only variable

Hello,

I have a class with a “virtual” read-only variable, i.e. there is only a getter for the variable; the getter computes the result based on other instance variables, e.g.

List<String> names;

public int getNamesCount() { return names.size(); }

I put an instance of this class as a process variable. When executing the process, I get an exception Cannot deserialize object in variable.... Only if I have a “real” variable with a getter and setter does the process run as expected.

I user the SPIN plugin with the JSON variant.

Is it possible to serialize and successfully deserialize an instance of a class with a read-only virtual variable?

Thanks for any hints.

Hi @fml2,

Mapping a JSON object to Java requires a setter method for all variables in that object.
SPIN is using Jackson under the hood which can be configured to ignore certain variables. Have a look here: https://docs.camunda.org/manual/latest/reference/spin/json/05-configuring-json/

Cheers,
Miklas

2 Likes