The last process variable (merchant) is a POJO called Merchant that contains a bunch of strings and an ArrayList of enum values.
When I execute the unit test I get the following error message:
**org.camunda.bpm.engine.ProcessEngineException: Cannot find serializer for value 'Untyped value 'model.Merchant@758f4f03''.**
Any idea what is going wrong? The process itself appears to work correctly when run inside a Tomcat instance running Camunda 7.4
Good to read that you were able to resolve that problem.
I guess the Camunda instance has additional serializers configured that enable serializing objects as JSON and XML, which are not present in your unit test setting (see the documentation on integrating Camunda Spin https://docs.camunda.org/manual/7.4/user-guide/data-formats/). Afaik, the XML serializer attempts to serialize any object if no other serializer is able to handle it.
If youāre relying on Camunda Spin to automatically serialise your object to JSON or XML then Iāve found adding Serializable actually breaks this functionality (youāll get a text representation of the Java object serialisation instead of JSON or XML). The error youāre receiving is likely related to not explicitly configuring the Camunda Spin plugin in the unit test engine i.e.
I totally agree with that: Serializable should not be needed if you use SPIN Dataformats.
But even with the SPIN plugin added to unit tests, the problem persists. The error is gone when I add āimplements Serializableā.
Here we see that SPIN is loaded with my custom configuration of the DataFormat (mapper)
[Test worker] INFO org.camunda.bpm.engine.cfg - ENGINE-12003 Plugin 'SpinProcessEnginePlugin' activated on process engine 'default'
[Test worker] INFO org.camunda.spin - SPIN-01010 Discovered Spin data format provider: org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormatProvider[name = application/json]
[Test worker] INFO org.camunda.spin - SPIN-01011 Discovered Spin data format configurator: class my.company.workflow.engine.config.JacksonDataFormatConfigurator[dataformat = org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormat]
[Test worker] INFO org.camunda.spin - SPIN-01009 Discovered Spin data format: org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormat[name = application/json]
[Test worker] INFO org.camunda.bpm.dmn.feel.scala - FEEL/SCALA-01001 Spin value mapper detected
[Test worker] INFO org.camunda.feel.FeelEngine - Engine created. [value-mapper: CompositeValueMapper(List(org.camunda.feel.impl.JavaValueMapper@81d998d, org.camunda.spin.plugin.impl.feel.integration.SpinValueMapper@648499b5)), function-provider: org.camunda.bpm.dmn.feel.impl.scala.function.CustomFunctionTransformer@381d6f65, configuration: Configuration(false)]
The test fails but is successful with āimplements Serializableā
In real life, the object is well managed by the engine (without āimplements Serializableā).
I remember vaguely from the past, that you can serialize to JSON, if you add the spin libraries and set the defaultSerializationFormat to application/json.
The objects were serialized as JSON without implementing Serializable.