Search code examples
javajacksonspring-data-rest

Spring Data Rest PersistentEntityResource Jackson serialization goes into StackOveflowError


I'm using the latest snapshot spring-data-rest-webmvc:2.0.0-SNAPSHOT. When Jackson tries to serialize PersistentEntityResource to JSON, it goes into an infinite loop on the "persistentEntity" property. I understand the property is supposed to be ignored, but it's not.

public class PersistentEntityResource<T> extends Resource<T> {
    @JsonIgnore private final PersistentEntity<?, ?> entity;
    ...
    public PersistentEntity<?, ?> getPersistentEntity() {
        return entity;
    }
}

Maybe Jackson sees the getter that doesn't match the name of the field and decides to serialize? Or do I have some configuration wrong?


Solution

  • I solved the problem by making sure that I don't have another bean in the spring context called "objectMapper". It was a default Jackson ObjectMapper that was overwriting the custom one configured in RepositoryRestMvcConfiguration.