org.springframework.http.converter.HttpMessageNotReadableException: Could not read an object of type class demo.Ticket from the request!; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException

Spring JIRA | Justin Lewis Salmon | 1 year ago
  1. 0

    I'm not sure if this is a regression, but it is basically the same issue as [DATAREST-491|https://jira.spring.io/browse/DATAREST-491] and [DATAREST-605|https://jira.spring.io/browse/DATAREST-605]. I'm seeing this using spring-boot-starter-data-rest:1.3.0.M5. Check out the [demo project|https://github.com/jlsalmon/mongo_data_rest] and do the following to reproduce: Create a resource: {code} curl -v -X POST http://localhost:8080/tickets -H "Content-Type: application/json" -d '{"properties" : {"a": "1", "b": {"c": "2"}}}' {code} Try to update the properties of the resource via PUT: {code} curl -v -X PUT http://localhost:8080/tickets/5640c0b6b760828633d03cca -H "Content-Type: application/json" -d '{"properties" : {"a": "3", "b": {"c": "4"}}}' {code} The following NPE is observed: {code} org.springframework.http.converter.HttpMessageNotReadableException: Could not read an object of type class demo.Ticket from the request!; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException at org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver.readPutForUpdate(PersistentEntityResourceHandlerMethodArgumentResolver.java:206) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] ... at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.28.jar:8.0.28] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25] Caused by: org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException at org.springframework.data.rest.webmvc.json.DomainObjectReader.merge(DomainObjectReader.java:138) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.readPut(DomainObjectReader.java:130) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.config.JsonPatchHandler.applyPut(JsonPatchHandler.java:134) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver.readPutForUpdate(PersistentEntityResourceHandlerMethodArgumentResolver.java:203) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] ... 52 common frames omitted Caused by: java.lang.NullPointerException: null at org.springframework.data.rest.webmvc.json.DomainObjectReader.getJacksonProperties(DomainObjectReader.java:254) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMerge(DomainObjectReader.java:158) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMergeNestedMap(DomainObjectReader.java:238) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMerge(DomainObjectReader.java:196) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.merge(DomainObjectReader.java:136) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] ... 55 common frames omitted {code}

    Spring JIRA | 1 year ago | Justin Lewis Salmon
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read an object of type class demo.Ticket from the request!; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException
  2. 0

    I'm not sure if this is a regression, but it is basically the same issue as [DATAREST-491|https://jira.spring.io/browse/DATAREST-491] and [DATAREST-605|https://jira.spring.io/browse/DATAREST-605]. I'm seeing this using spring-boot-starter-data-rest:1.3.0.M5. Check out the [demo project|https://github.com/jlsalmon/mongo_data_rest] and do the following to reproduce: Create a resource: {code} curl -v -X POST http://localhost:8080/tickets -H "Content-Type: application/json" -d '{"properties" : {"a": "1", "b": {"c": "2"}}}' {code} Try to update the properties of the resource via PUT: {code} curl -v -X PUT http://localhost:8080/tickets/5640c0b6b760828633d03cca -H "Content-Type: application/json" -d '{"properties" : {"a": "3", "b": {"c": "4"}}}' {code} The following NPE is observed: {code} org.springframework.http.converter.HttpMessageNotReadableException: Could not read an object of type class demo.Ticket from the request!; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException at org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver.readPutForUpdate(PersistentEntityResourceHandlerMethodArgumentResolver.java:206) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] ... at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.28.jar:8.0.28] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25] Caused by: org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException at org.springframework.data.rest.webmvc.json.DomainObjectReader.merge(DomainObjectReader.java:138) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.readPut(DomainObjectReader.java:130) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.config.JsonPatchHandler.applyPut(JsonPatchHandler.java:134) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver.readPutForUpdate(PersistentEntityResourceHandlerMethodArgumentResolver.java:203) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] ... 52 common frames omitted Caused by: java.lang.NullPointerException: null at org.springframework.data.rest.webmvc.json.DomainObjectReader.getJacksonProperties(DomainObjectReader.java:254) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMerge(DomainObjectReader.java:158) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMergeNestedMap(DomainObjectReader.java:238) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMerge(DomainObjectReader.java:196) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] at org.springframework.data.rest.webmvc.json.DomainObjectReader.merge(DomainObjectReader.java:136) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na] ... 55 common frames omitted {code}

    Spring JIRA | 1 year ago | Justin Lewis Salmon
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read an object of type class demo.Ticket from the request!; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException
  3. 0

    tried to call rest webservice, and got this exception thrown only on HTC Incredible S, tested on other device working fine W/System.err( 3433): org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: BufferedInputStream is closed; nested exception is java.io.IOException: BufferedInputStream is closed W/System.err( 3433): at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:125) W/System.err( 3433): at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:147) W/System.err( 3433): at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:76) W/System.err( 3433): at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:655) W/System.err( 3433): at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:641) W/System.err( 3433): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:484) W/System.err( 3433): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439) W/System.err( 3433): at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:415)

    Spring JIRA | 4 years ago | Aphiwad Chhoeun
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: BufferedInputStream is closed; nested exception is java.io.IOException: BufferedInputStream is closed
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    User - weird problems deserializing

    nabble.com | 1 year ago
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class com.foo.service.inrix.auth.InrixGetSecurityTokenResponse]; nested exception is org.springframework.oxm.UnmarshallingFailureException: XStream unmarshalling exception; nested exception is com.thoughtworks.xstream.mapper.CannotResolveClassException: Inrix
  6. 0

    [GPREST-13] Rest-client-Builder cannot read valid JSON after upgrading from grails 2.4.4 to 2.5.0 - Grails JIRA

    grails.org | 1 year ago
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2; nested exception is com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.http.converter.HttpMessageNotReadableException

      Could not read an object of type class demo.Ticket from the request!; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException

      at org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver.readPutForUpdate()
    2. Spring Data REST - WebMVC
      PersistentEntityResourceHandlerMethodArgumentResolver.readPutForUpdate
      1. org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver.readPutForUpdate(PersistentEntityResourceHandlerMethodArgumentResolver.java:206)[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
      1 frame