Skip to content

AbstractJackson2HttpMessageConverter is incompatible with Jackson 2.7+ [SPR-13870] #18443

Closed
@spring-projects-issues

Description

@spring-projects-issues

Abhijit Sarkar opened SPR-13870 and commented

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:

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)

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions