java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType;

Spring JIRA | Abhijit Sarkar | 11 months ago
  1. 0

    {{AbstractJackson2HttpMessageConverter.getJavaType}} calls {{objectMapper.getTypeFactory().constructType(type, contextClass)}}. In Jackson 2.7+, they modified the signature of {{constructType}} and it doesn't take a 2nd {{Class}} argument anymore. This is breaking everything that uses the {{AbstractJackson2HttpMessageConverter}}, including {{RestTemplate}} and controllers that output JSON. {{AbstractJackson2HttpMessageConverter}} claims that it is "Compatible with Jackson 2.1 and higher." but that's not true anymore. The newer Jackson has features that are very desirable, like customization options for JDK8 date time, so downgrading is not a viable option for modern clients. Sample stacktrace: {code} java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType; at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.getJavaType(AbstractJackson2HttpMessageConverter.java:311) at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:146) at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:141) at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:706) at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:769) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:594) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:572) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:493) {code}

    Spring JIRA | 11 months ago | Abhijit Sarkar
    java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType;
  2. 0

    {{AbstractJackson2HttpMessageConverter.getJavaType}} calls {{objectMapper.getTypeFactory().constructType(type, contextClass)}}. In Jackson 2.7+, they modified the signature of {{constructType}} and it doesn't take a 2nd {{Class}} argument anymore. This is breaking everything that uses the {{AbstractJackson2HttpMessageConverter}}, including {{RestTemplate}} and controllers that output JSON. {{AbstractJackson2HttpMessageConverter}} claims that it is "Compatible with Jackson 2.1 and higher." but that's not true anymore. The newer Jackson has features that are very desirable, like customization options for JDK8 date time, so downgrading is not a viable option for modern clients. Sample stacktrace: {code} java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType; at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.getJavaType(AbstractJackson2HttpMessageConverter.java:311) at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:146) at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:141) at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:706) at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:769) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:594) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:572) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:493) {code}

    Spring JIRA | 11 months ago | Abhijit Sarkar
    java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType;
  3. 0

    GitHub comment 78#182787263

    GitHub | 10 months ago | robertgmoss
    java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType;
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    SpringMVC转换Json 出错.java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.t_「电脑玩物」中文网我们只是「电脑玩物」 -

    07net01.com | 8 months ago
    java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType
  6. 0

    Spring 4.2.3 and fasterxml Jackson 2.7.0 are incompatible

    Stack Overflow | 11 months ago | Marek Raszewski
    java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType;

    2 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. java.lang.NoSuchMethodError

      com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType;

      at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.getJavaType()
    2. Spring
      RestTemplate.exchange
      1. org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.getJavaType(AbstractJackson2HttpMessageConverter.java:311)
      2. org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:146)
      3. org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:141)
      4. org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:706)
      5. org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:769)
      6. org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:594)
      7. org.springframework.web.client.RestTemplate.execute(RestTemplate.java:572)
      8. org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:493)
      8 frames