Setting process variable to List of Maps

My use case is that of multiple parallel subprocesses. This needs for me to set a process variable to an object that implement collections.

I am trying to set the variable to an ArrayList of HashMaps. ArrayLists implements List which extends Collection. And Both HashMaps and ArrayLists are serializable which seem to be the requirement for process variables of the type that I need.

Now when I do execution.setVariable(<variable_name>, <variable_value>);
It throws an exception saying

“Cannot find serializer for value ‘Untyped value ‘[{<key_in_map>=<value_for_key>}]’’.”

I will greatly appreciate if someone can guide me on this or show me an example of setting variables in multiInstance processes.

Can you please provide a test case reproducing this on github? You can use the following project to get started:

Hi Thorben,

I was just wondering if execution.setVariable will work if the value of the variable is a List/HashMap/List?
I am new to coding in Java and am doing this in a company env which facilitates a lot of tooling so reproducing may take time for me.

Let me know if that question is basic enough to answer directly or I will work on reproducing the problem.

Thanks,
Akhil.

HI Akhil,

In general, setting variables to instances of ArrayList and HashMap works, as well as nesting them in each other. It may not work for various reasons, e.g. an incorrectly configured process engine. That’s why a unit test would be very helpful.

Btw being able to write unit tests with Camunda’s test infrastructure could be a useful skill anyway :slight_smile: The linked github project gives you a directly executable Maven project that includes an example test case.

Cheers,
Thorben

Can I provide the configuration for digging deeper?
The project I am using is built using gradle and not maven, what file in here is similar to pom.xml that I can provide to see if engine is configured correctly?

Also in a general case does this need spin configured?

Thanks,
Akhil.