org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized field "_embedded" (Class com.foo.support.model.Person), not marked as ignorable at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@d4aff35; line: 2, column: 18] (through reference chain: com.foo.support.model.Person["_embedded"]); nested exception is org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "_embedded" (Class com.foo.support.model.Person), not marked as ignorable at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@d4aff35; line: 2, column: 18] (through reference chain: com.foo.support.model.Person["_embedded"])

Stack Overflow | SST | 3 months ago
  1. 0

    how to map spring-data-rest JSON response with its object using RestTEmplate

    Stack Overflow | 3 months ago | SST
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized field "_embedded" (Class com.foo.support.model.Person), not marked as ignorable at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@d4aff35; line: 2, column: 18] (through reference chain: com.foo.support.model.Person["_embedded"]); nested exception is org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "_embedded" (Class com.foo.support.model.Person), not marked as ignorable at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@d4aff35; line: 2, column: 18] (through reference chain: com.foo.support.model.Person["_embedded"])
  2. 0

    Carried over from SOCIAL-423: I tried the latest build but I get org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: No suitable constructor found for type [simple type, class org.springframework.social.facebook.api.FacebookProfile]: can not instantiate from JSON object (need to add/enable type information?) at [Source: java.io.ByteArrayInputStream@7e305fb2; line: 1, column: 2]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class org.springframework.social.facebook.api.FacebookProfile]: can not instantiate from JSON object (need to add/enable type information?) at [Source: java.io.ByteArrayInputStream@7e305fb2; line: 1, column: 2] at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readJavaType(MappingJackson2HttpMessageConverter.java:228) at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.read(MappingJackson2HttpMessageConverter.java:220) at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:95) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:549) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:517) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:255) at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:165) at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:50) at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:46) exception

    Spring JIRA | 3 years ago | Craig Walls
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: No suitable constructor found for type [simple type, class org.springframework.social.facebook.api.FacebookProfile]: can not instantiate from JSON object (need to add/enable type information?) at [Source: java.io.ByteArrayInputStream@7e305fb2; line: 1, column: 2]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class org.springframework.social.facebook.api.FacebookProfile]: can not instantiate from JSON object (need to add/enable type information?) at [Source: java.io.ByteArrayInputStream@7e305fb2; line: 1, column: 2]
  3. 0

    Getting exception - Could not read JSON: Unrecognized field "CatalogGrpView"

    Coderanch | 4 months ago | saravanan sambandam
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized field "CatalogGrpView" (Class com.marcom.model.catalog.CatalogVO), not marked as ignorable at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@69e9c8ed; line: 1, column: 44] (through reference chain: com.marcom.model.catalog.CatalogVO["CatalogGrpView"]); nested exception is org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "CatalogGrpView" (Class com.marcom.model.catalog.CatalogVO), not marked as ignorable at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@69e9c8ed; line: 1, column: 44] (through reference chain: com.marcom.model.catalog.CatalogVO["CatalogGrpView"])
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring RestTemplate failure with upper case element names

    Stack Overflow | 9 months ago | No Spam
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized field "OTPRO" (class com.ssdr.rest.message.SSDRResponse), not marked as ignorable (7 known properties: "dt", "ot", "message", "otpro", "otphone", "code", "dtphone"]) at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@4ccbe679; line: 4, column: 14] (through reference chain: com.ssdr.rest.message.SSDRResponse["OTPRO"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "OTPRO" (class com.ssdr.rest.message.SSDRResponse), not marked as ignorable (7 known properties: "dt", "ot", "message", "otpro", "otphone", "code", "dtphone"]) at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@4ccbe679; line: 4, column: 14] (through reference chain: com.ssdr.rest.message.SSDRResponse["OTPRO"])
  6. 0

    Hi guys, I have the following JPA mapping: {code} @Entity public class Product { @ElementCollection(fetch = FetchType.LAZY) @CollectionTable(name = "product_name_lv", joinColumns = @JoinColumn(name = "product_pk")) @MapKeyColumn(name = "locale") @MapKeyJoinColumn(name = "language", referencedColumnName = "isocode") private Map<Locale, LocalizedValue> name = new HashMap<Locale, LocalizedValue>(); } {code} where the LocalizedValue is a simple POJO class: {code} @Embeddable public class LocalizedValue { @Column(name = "VALUE") private String value; } {code} So SDR works good and returns my product, like a normal json: {code} "name" : { "bg" : { "value" : "FOO" }, "en" : { "value" : "BAR" }, "de" : { "value" : "German FOO" } }, {code} So far so good I try to make a PUT request with the same json data, it yields with: {code} 2013-10-19 13:05:57,726 [qtp508751118-134] ERROR: Could not read JSON: Unrecognized field "en" (class com.xxxxxx.platform.core.model.i18n.LocalizedValue), not marked as ignorable (one known property: "value"]) at [Source: org.eclipse.jetty.server.HttpInput@63497f5b; line: 1, column: 30] (through reference chain: com.xxxxx.platform.core.model.i18n.LocalizedValue["en"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "en" (class com.xxxxxx.platform.core.model.i18n.LocalizedValue), not marked as ignorable (one known property: "value"]) at [Source: org.eclipse.jetty.server.HttpInput@63497f5b; line: 1, column: 30] (through reference chain: com.xxxxx.platform.core.model.i18n.LocalizedValue["en"]) org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized field "en" (class com.xxxxxx.platform.core.model.i18n.LocalizedValue), not marked as ignorable (one known property: "value"]) at [Source: org.eclipse.jetty.server.HttpInput@63497f5b; line: 1, column: 30] (through reference chain: com.xxxxxx.platform.core.model.i18n.LocalizedValue["en"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "en" (class com.xxxxxx.platform.core.model.i18n.LocalizedValue), not marked as ignorable (one known property: "value"]) at [Source: org.eclipse.jetty.server.HttpInput@63497f5b; line: 1, column: 30] (through reference chain: com.xxxxxx.platform.core.model.i18n.LocalizedValue["en"]) at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readJavaType(MappingJackson2HttpMessageConverter.java:181) at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readInternal(MappingJackson2HttpMessageConverter.java:166) at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:153) at org.springframework.data.rest.webmvc.PersistentEntityResourceHandlerMethodArgumentResolver.resolveArgument(PersistentEntityResourceHandlerMethodArgumentResolver.java:48) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77) at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:849) at javax.servlet.http.HttpServlet.service(HttpServlet.java:758) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482) at org.apache.logging.log4j.core.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:66) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482) at com.xxxxxx.platform.modules.rest.mvc.filter.CorsFilter.doFilterInternal(CorsFilter.java:23) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1474) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:370) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:722) {code} So I started digging in the code and I think the problem happens in PersistentEntityJackson2Module:197. I can see there an if-statement which checks if the property is of type map: {code} } else if (persistentProperty.isMap()) { Class<? extends Map<?, ?>> mtype = (Class<? extends Map<?, ?>>) persistentProperty.getType(); Map<Object, Object> m = (Map<Object, Object>) wrapper.getProperty(persistentProperty); if (null == m || m == Collections.EMPTY_MAP) { m = new HashMap<Object, Object>(); } if ((tok = jp.nextToken()) == JsonToken.START_OBJECT) { do { name = jp.getCurrentName(); // TODO resolve domain object from URI tok = jp.nextToken(); Object mval = jp.readValueAs(persistentProperty.getMapValueType()); //<-- this line reads as persistent property map value type. m.put(name, mval); } while ((tok = jp.nextToken()) != JsonToken.END_OBJECT); val = m; } else if (tok == JsonToken.VALUE_NULL) { val = null; } else { throw new HttpMessageNotReadableException("Cannot read a JSON " + tok + " as a Map."); } {code} So it basically gets the type of the persistent property, creates an empty map, iterates over the json, and reads the value of the original map (i.e. what will be placed after name: ) as the value of the persistent property map (LocalizedValue in my case). Which is wrong I think. It should read it as a map imho.

    Spring JIRA | 3 years ago | Petar Tahchiev
    org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized field "en" (class com.xxxxxx.platform.core.model.i18n.LocalizedValue), not marked as ignorable (one known property: "value"]) at [Source: org.eclipse.jetty.server.HttpInput@63497f5b; line: 1, column: 30] (through reference chain: com.xxxxxx.platform.core.model.i18n.LocalizedValue["en"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "en" (class com.xxxxxx.platform.core.model.i18n.LocalizedValue), not marked as ignorable (one known property: "value"]) at [Source: org.eclipse.jetty.server.HttpInput@63497f5b; line: 1, column: 30] (through reference chain: com.xxxxxx.platform.core.model.i18n.LocalizedValue["en"])

    1 unregistered visitors
    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 JSON: Unrecognized field "_embedded" (Class com.foo.support.model.Person), not marked as ignorable at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@d4aff35; line: 2, column: 18] (through reference chain: com.foo.support.model.Person["_embedded"]); nested exception is org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "_embedded" (Class com.foo.support.model.Person), not marked as ignorable at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@d4aff35; line: 2, column: 18] (through reference chain: com.foo.support.model.Person["_embedded"])

      at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal()
    2. Spring
      RestTemplate.getForObject
      1. org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:127)[spring-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]
      2. org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:153)[spring-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]
      3. org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:81)[spring-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]
      4. org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:446)[spring-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]
      5. org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)[spring-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]
      6. org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:199)[spring-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]
      6 frames