Rest API failing to respond for variables that contain LocalDateTime

Hello!

First of all, we are currently running Camunda Platform 7.16 with Spring-boot.

We have been struggling a lot with Java 8 LocalDate and LocalDateTime.

Our latest issue is, that when we try to view any object from cockpit with localDateTime in it, we get a http 400.

It appears to originate from the rest API which repsonds to the variable query with:

Java 8 date/time type java.time.LocalDateTime not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.camunda.bpm.engine.rest.dto.history.HistoricVariableInstanceDto["value"]->actual.classpathHidden.SomeRandomDto["creationTime"])

We already have in our pom.xml (well, the super-pom to be precise):

<!-- Time OUT/IN JSON handling-->
            <dependency>
                <groupId>com.fasterxml.jackson.datatype</groupId>
                <artifactId>jackson-datatype-jsr310</artifactId>
                <version>${jackson.version}</version>
            </dependency>

jackson-version is 2.13.0 if it matters.

This does the trick so that our Java code in the delegates can handle to LocalDates and LocaDateTimes, but rest api is still failing to present them.

Can someone help us understand what we are missing?

Hello @JussiL ,

do you have SPIN for data serialization?
If yes, do you use dataformat-all?
If yes, change it to dataformat-jackson-json.

The problem is that dataformat-all uses shaded jackson which is (as I see it) not able to be extended.

This is why you need dataformat-jackson-json if you want to extend it engine-wise.

I hope this helps.

Jonathan

Hi Jonathan!

Thanks for the reply. I will definetly try it.

-Jussi

Hello,

I’m having the exact same issue. I tried importing the “camunda-spin-dataformat-json-jackson” and “jackson-datatype-jsr310” maven dependency into my SpringBoot project, but I still haven’t managed to fix the issue.

@jonathan.lukas could you please elaborate more on this?

Below is the object I’m trying to serialize/deserialize to/from the Camunda variables:

public class Header implements Serializable {

    @Serial
    private static final long serialVersionUID = -5272626023141301251L;

    private String trackingId;
    private String systemName;

    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
    private LocalDateTime creationDateTime;
}

Below is the Object Mapper configuration to enable jackson-datatype-jsr310:

    @Bean
    public ObjectMapper objectMapper() {
        return JsonMapper.builder()
                .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
                .addModule(new JavaTimeModule())
                .build();
    }

Below is the error I get when I try to view the object on the Cockpit page:

The error returned is the following:

{“type”:“InvalidRequestException”,“message”:“”}

Hello @nmanitaras ,

is there a specific reason why you are serializing the process variable as java serialized object?

Using spin and configuring the default serialization format of the engine to be application/json will help you to eliminate java serialization which is error prone thanks to a tight coupling to the classpath.
Plus, there is only one serialization format for everything.

Jonathan

I managed to change the data serialization format to application/json, but I still get the same exception:

Also, I just realized that the error is randomly switching between:

{“type”:“InvalidRequestException”,“message”:“”}

and

Java 8 date/time type java.time.LocalDateTime not supported by default: add Module “com.fasterxml.jackson.datatype:jackson-datatype-jsr310”

The only workaround I’ve found is to use a String instead of a LocalDateTime, but I would really like to avoid this.

We just updated to 7.17 and at same time the developer doing it updated dataformat to

<dependency>
            <groupId>org.camunda.spin</groupId>
            <artifactId>camunda-spin-dataformat-all</artifactId>
            <version>1.15.0</version>
</dependency>

And the issue stopped happening.

1 Like