I fixed this by adding

@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class User {

to my User.java class

Answer from Peter Boomsma on Stack Overflow
Discussions

postgis - Failing to deserialize geometry point data in Spring Boot REST API - Geographic Information Systems Stack Exchange
I am working on a location-based REST API and so far everything is working fine, except for one controller which gives this error. I am new to this. 2022-03-16 16:28:37.842 WARN 7720 --- [nio-808... More on gis.stackexchange.com
🌐 gis.stackexchange.com
March 18, 2022
java - Jackson failed to deserialization OneToMany objects - Stack Overflow
I have faced with the problem that converter can't handle JSON object. I have two objects in data base. Relationship OneToMany. I have a AutoService with many services. And wnen i am trying to s... More on stackoverflow.com
🌐 stackoverflow.com
January 14, 2019
Failed to evaluate Jackson deserialization in spring boot api - Stack Overflow
this is error 20-01-22 Wed 14:17:56.475 WARN MappingJackson2HttpMessageConverter Failed to evaluate Jackson deserialization for type [[simple type, class lk.andunaechomedia.models.Device]]: com.fasterxml.jackson.databind.JsonMappingException: Multiple back-reference properties with name ... More on stackoverflow.com
🌐 stackoverflow.com
java - Failed to evaluate Jackson deserialization - Stack Overflow
2018-06-04 21:41:31.645 WARN 508 --- [nio-8443-exec-6] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson deserialization for type [[simple type, class com.jonki.popcorn.common.dto.request.ContributionNewRequest]]: com.fasterx... More on stackoverflow.com
🌐 stackoverflow.com
June 4, 2018
🌐
GitHub
github.com › spring-projects › spring-data-rest › issues › 2023
Jackson deserialization fails (Spring Boot 2.5) · Issue #2023 · spring-projects/spring-data-rest
June 8, 2021 - RepositoryRestMvcConfiguration$ResourceSupportHttpMessageConverter Failed to evaluate Jackson deserialization for type [[simple type, class org.springframework.data.rest.webmvc.PersistentEntityResource]]: java.lang.NullPointerException: Cannot invoke "org.springframework.data.util.TypeInformation.getActualType()" because "propertyType" is null ·
Author: spring-projects
🌐
Google Groups
groups.google.com › g › jackson-user › c › GnMZmsQ5U7s
ObjectMapper with Jackson2HalModule registered throws NPE when tries to deserialize "Resources" type
2017-08-03 14:31:48.175 WARN 11792 --- [ main] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson deserialization for type [[simple type, class org.springframework.hateoas.Resources<org.springframework.hateoas.Resource<com.example.persontest.domain.Person>>]]: java.lang.NullPointerException ·
🌐
Stack Exchange
gis.stackexchange.com › questions › 426423 › failing-to-deserialize-geometry-point-data-in-spring-boot-rest-api
postgis - Failing to deserialize geometry point data in Spring Boot REST API - Geographic Information Systems Stack Exchange
March 18, 2022 - 2022-03-16 16:28:37.847 WARN 7720 --- [nio-8080-exec-5] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson deserialization for type [[simple type, class com.example.Producttracking.dto.MetadataDto]]: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Conflicting setter definitions for property "x": org.postgis.Point#setX(double) vs org.postgis.Point#setX(int)
🌐
Baeldung
baeldung.com › home › json › jackson › jackson exceptions – problems and solutions
Jackson Exceptions - Problems and Solutions | Baeldung
April 8, 2024 - The stack trace of the exception says it all: “Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)“. It means that Jackson fails to deserialize an object into a String instance.
Find elsewhere
🌐
Trifork Blog
trifork.nl › home › i used spring’s resttemplate to fetch some json, and you won’t believe what happened next!
I used Spring’s RestTemplate to fetch some JSON, and you won’t believe what happened next! - Trifork Blog
May 26, 2020 - Failed to evaluate Jackson deserialization for type [[simple type, class mypackage.SomeResponseType]]: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Invalid type definition for type `mypackage.SomeResponseType`: Argument #0 has no property name, is not Injectable: can not use as Creator [constructor for mypackage.SomeResponseType, annotations: {interface com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator(mode=DEFAULT)}]
🌐
SAP Community
community.sap.com › t5 › crm-and-cx-q-a › quick-order-throwing-exception-hybris-1905 › qaq-p › 12043339
Quick Order throwing exception Hybris 1905 - SAP Community
November 17, 2024 - Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type. ... Success! Subscription added. ... [MappingJackson2HttpMessageConverter] Failed to evaluate Jackson deserialization for type [[simple type, class de.hybris.platform.acceleratorstorefrontcommons.forms.AddToCartOrderForm]]: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "url": de.hybris.platform.core.model.media.MediaModel#setUrl(1 params) vs de.hybris.platform.core.model.media.MediaModel#setURL(1 params) WARN [hybrisHTTP26] [MappingJackso
🌐
Stack Overflow
stackoverflow.com › questions › 50575534 › failed-to-evaluate-jackson-deserialization-cannot-handle-managed-back-reference
spring mvc - Failed to evaluate Jackson deserialization ,Cannot handle managed/back reference 'defaultReference' (Json) - Stack Overflow
[org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.logWarningIfNecessary(AbstractJackson2HttpMessageConverter.java:205)] Failed to evaluate Jackson deserialization for type [[simple type, class com.rasvek.cg.entity.StudentAdmissinAssoDTO]]: java.lang.IllegalArgumentException: Can not handle managed/back reference 'defaultReference': no back reference property found from type [collection type; class java.util.Set, contains [simple type, class com.rasvek.cg.entity.MasterAddress]]
🌐
GitHub
github.com › spring-projects › spring-framework › issues › 18735
MappingJackson2HttpMessageConverter should not always log a warning [SPR-14163] · Issue #18735 · spring-projects/spring-framework
April 13, 2016 - 2016-04-13 13:22:30.760 WARN [app-service] 15947 --- [AppClient-1] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate deserialization for type [simple type, class com.company.product.component.protobuf.Client$Configurations]: com.fasterxml.jackson.databind.JsonMappingException: Can not find a (Map) Key deserializer for type [simple type, class com.google.protobuf.Descriptors$FieldDescriptor]
Author: spring-projects
Top answer
1 of 1
1

I wouldn't suggest exposing entities directly to your controller. Entities should only contain JPA annotations in your case. You can expose a DTO (Data Transfer Object) to your controller and then map the DTO to the corresponding entity.

ReviewDto

public class ReviewDto {
    private String reviewDescription;

    private double courseRating;

    private CourseDto course;

    // getters, setters, etc
}

CourseDto

public class CourseDto {
    private Long id;

    private String name;

    private String description;

    // professorDto, getters, setters, etc
}

An example demonstrating how your controller class will be

@RestController
public class DemoController {
    private final ReviewDtoMapper reviewDtoMapper;
    private final ReviewService reviewService;

    public DemoController(ReviewDtoMapper reviewDtoMapper,
                          ReviewService reviewService) {
        this.reviewDtoMapper = reviewDtoMapper;
        this.reviewService = reviewService;
    }

    @PostMapping(value = "demo")
    public ResponseEntity<String> postReview(@RequestBody ReviewDto reviewDto) {
        final Review review = reviewDtoMapper.mapFrom(reviewDto);

        reviewService.save(review);

        return ResponseEntity.ok("");
    }
}

The class to map from reviewDto to review entity and the opposite.

@Component
public class ReviewDtoMapper {

    public ReviewDto mapTo(final Review entity) {

        ReviewDto reviewDto = new ReviewDto();
        reviewDto.setReviewDescription(entity.getReviewDescription());
        // set all the properties you want
        return reviewDto;
    }


    public Review mapFrom(ReviewDto dto) {

        Review review = new Review();
        review.setReviewDescription(dto.getReviewDescription());
        // set all the properties you want
        return review;
    }
}

Of course, you have to make adjustments according to your needs.

If you like this way of doing things I would suggest you check MapStruct, it will automatically make the mappers for you.

🌐
GitHub
github.com › spring-projects › spring-framework › issues › 31829
[3.2.0] Jackson Deserialization fails in Spring Controller (works fine in Spring 3.1.x) · Issue #31829 · spring-projects/spring-framework
December 13, 2023 - UserCounterValue uses polymorphism with json "@type" field: @JsonTypeInfo(use = NAME, include = PROPERTY) public interface UserCounterValue extends UserEntity, BenchResultEntity { } And both concrete beans implementing this interface are declared in Jackson using mapper.registerSubTypes(...). When running a junit which uses Retrofit to send the bean to the backend, it fails:
🌐
YouTube
youtube.com › shane lee
Quick Fix: JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` - YouTube
In this video, we go through solving this rather annoying Java Jackson Deserialization error: JSON parse error: Cannot deserialize value of type `java.time.L...
Published: July 31, 2020
Views: 235
🌐
Snyk
snyk.io › blog › java-json-deserialization-problems-jackson-objectmapper
Java JSON deserialization problems with the Jackson ObjectMapper | Snyk
December 1, 2021 - For reference, check the list of deserialization vulnerabilities on the jackson-databind library on the Snyk vulnerability database. Ok, don’t panic because it is not that bad. First of all, the maintainers of the jackson-databind library actively block the set of “nasty classes” in the SubTypeValidator. Secondly, you need to enable default types explicitly.
🌐
GitHub
github.com › zalando › problem › issues › 356
Unable to deserialize Problem with Jackson · Issue #356 · zalando/problem
January 10, 2022 - Failed to call `setAccess()` on Constructor 'org.zalando.problem.DefaultProblem' due to `java.lang.reflect.InaccessibleObjectException`, problem: Unable to make org.zalando.problem.DefaultProblem(java.net.URI,java.lang.String,org.zalando.problem.StatusType,java.lang.String,java.net.URI,org.zalando.problem.ThrowableProblem) accessible: module org.zalando.problem does not "opens org.zalando.problem" to module com.fasterxml.jackson.databind
Author: zalando
🌐
w3tutorials
w3tutorials.net › blog › jackson-deserialization-error-handling
Jackson Deserialization Error Handling: How to Ignore Invalid Type Mappings (String to Int Example) — w3tutorials.net
In modern Java applications, JSON deserialization is a critical task, often handled by the popular library Jackson. While Jackson excels at mapping JSON data to Java objects, it can be unforgiving when faced with type mismatches—for example, a JSON string where a Java integer is expected.