Java Objects in Camunda workflow


I have a process with several system task. Each task is calling an outside API to do some validation of data in those systems. If the validation fails, i will have to store the errors in an object in the camunda process. The error object will contain a list of ErrorSource (from which external system the error comes from), and each of the ErrorSource will contain a list of errors (string types).

So, how do I create and manipulate the object after each task. And, how is the object persisted if the camunda goes down, etc?



You want to set one or more process variables in your service task. Camunda stores them in the database as part of the respective process instance. Every service task can set process variables. In a Java Delegate:

public class MyServiceTaskDelegate implements JavaDelegate {

    public void execute(DelegateExecution execution) throws Exception {
        HttpConnector http = Connectors.getConnector(HttpConnector.ID);
        HttpResponse httpResponse = http.createRequest()
        String body = httpResponse.getResponse();
        // extract error object from body
        execution.setVariable("errorObject", errorObject);

Note that you need an embedded html form to display data from a complex object in a user task. Generated forms can only see scalar process variables.


First of all. Many thanks for your answer.

My problem is that I am only able to put String, etc on the process, as you describe. If I try to put an custom object, as the ErrorSource over, I get an error like I have described here:

Again, thank you for your help.



A JavaDelegate can store Java object instances as process variables, provided that the class is on Camunda’s classpath.

Is it an option for you to write a JavaDelegate as shown above and enter its full class name in your service task’s properties:


Hi @dschulten

I have to use delegate expression, because spring boot autowiring doesnt work with java delegate. But, even if I use java delegate or delegate expression, the class I delegate to, is not able to put objects on the process instance.

Which delegate expression do you use and how do you pass data into the spring bean method?


Hi, thanks for your response.

The java class is set up like this:
public class GetCaseworkDelegate implements JavaDelegate {

Int the system task in BPMN, i have added the javaDelegate like this:
<bpmn:serviceTask id=“Task_0ftz2se” name=“Get Casework” camunda:delegateExpression="${getCaseworkDelegate}">

Everything works fine, except when i try to add a custom (homemade) object to the process, like this:

TestDTO testDTO = new TestDTO();
execution.setVariable(“TestDTO”, testDTO);

Then I get the serializer error.

The serialization issue has been resolved in Put/get java object on process with java delegate