Custom serializer configuration

Hi!

I have a process instance global variable containing a JPA entity. My application is a simple spring boot application using flowable-spring-boot-starter-rest.
Everything works fine until I try to retrieve the variable value with rest api (http://…/process-api/runtime/tasks//variables//data) when I get a java.io.NotSerializableException. I understand the problem and I read the note about custom serializer in https://www.flowable.org/docs/userguide/index.html#restVariables but it’s not clear to me how to do it.

I’d like to serialize the entity as json, and I tried to add this bean in my configuration, but it seems to me that it’s ignored:

@Bean
public DmnRestResponseFactory dmnRestResponseFactory() {
    return new DmnRestResponseFactory() {
        @Override
        protected void initializeVariableConverters() {
            super.initializeVariableConverters();
            variableConverters.add(shipmentDataConverter());
        }
    };
}

Is there any example of how to register a custom serializer?

Thank you in advance for any help.

Andrea

1 Like

Hey Andrea,

I would presume that you are using the Spring Boot auto-configuration from Flowable. It seems that currently you can’t override the DmnRestReponseFactory bean. The reason why your bean is not picked up is that the Rest Servlet is registered in a child context via the DmnEngineRestConfiguration in the RestApiAutoConfiguration.DmnEngineRestApiConfiguration.

If you want you can create a PR that would allow you to add custom converters to the DmnRestResponseFactory.

Cheers,
Filip