Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Databind 2.9.9.2 not working with Spring Boot 2.1 - "No converter found for return value of type: class com.fasterxml.jackson.databind.node.ObjectNode #2412

Closed
sseide opened this issue Aug 6, 2019 · 3 comments

Comments

@sseide
Copy link

sseide commented Aug 6, 2019

We have an Spring boot application that just returns an ObjectMapper Object to build some custom JSON responses. It was working up to jackson-databind 2.9.9.1. Only changing jackson-databind to latest version 2.9.9.2 it throws an NullPointerException during serialization

The following three files contain a minimal Spring boot Application running under OpenJDK 11.0.3

It contains the following version, they only differ at jackson-databind version
jackson-core 2.9.9
spring boot 2.1.6.RELEASE

The test project consist of the following three files - please rename uploaded files accordingly
pom.txt
Application.txt
TestController.txt

pom.xml
src/main/java/jackson/Application.java
src/main/java/jackson/TestController.java

Tested with curl on command line - working version:

$ curl -i http://localhost:8080/test/
HTTP/1.1 200 
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 06 Aug 2019 11:11:53 GMT

{"uuid":"98137bad-4240-4c3f-bd03-51e2ae69e5c2"}

Non-working version with databind 2.9.9.2

$ curl -i http://localhost:8080/test/
HTTP/1.1 500 
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 06 Aug 2019 11:13:57 GMT
Connection: close

{"timestamp":"2019-08-06T11:13:57.253+0000","status":500,"error":"Internal Server Error","message":"No converter found for return value of type: class com.fasterxml.jackson.databind.node.ObjectNode","path":"/test/"}

The spring boot log from the non-working version is

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.6.RELEASE)

2019-08-06 13:13:50.810  INFO 32432 --- [           main] jackson.Application                      : Starting Application on schleppi with PID 32432 (/home/user/workspaces/jackson-test/target/classes started by user in /home/user/workspaces/jackson-test)
2019-08-06 13:13:50.819  INFO 32432 --- [           main] jackson.Application                      : No active profile set, falling back to default profiles: default
2019-08-06 13:13:51.591  INFO 32432 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-08-06 13:13:51.608  INFO 32432 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-08-06 13:13:51.608  INFO 32432 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-08-06 13:13:51.654  INFO 32432 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-08-06 13:13:51.654  INFO 32432 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 802 ms
2019-08-06 13:13:51.783  INFO 32432 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-08-06 13:13:51.896  INFO 32432 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-08-06 13:13:51.899  INFO 32432 --- [           main] jackson.Application                      : Started Application in 1.3 seconds (JVM running for 1.707)
2019-08-06 13:13:57.219  INFO 32432 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-08-06 13:13:57.220  INFO 32432 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-08-06 13:13:57.224  INFO 32432 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 4 ms
2019-08-06 13:13:57.243  WARN 32432 --- [nio-8080-exec-1] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson serialization for type [class com.fasterxml.jackson.databind.node.ObjectNode]: java.lang.NullPointerException
2019-08-06 13:13:57.243  WARN 32432 --- [nio-8080-exec-1] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson serialization for type [class com.fasterxml.jackson.databind.node.ObjectNode]: java.lang.NullPointerException
2019-08-06 13:13:57.247  WARN 32432 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class com.fasterxml.jackson.databind.node.ObjectNode]

Thanks,
Stefan Seide

@cowtowncoder
Copy link
Member

I'm pretty sure this is due to #2395, fixed in just released 2.9.9.3 of jackson-databind.

@sseide
Copy link
Author

sseide commented Aug 6, 2019

yes, working again with new 2.9.9.3

@cowtowncoder
Copy link
Member

@sseide thank you for verifying this, confirming fix works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants