Attempting to browse to /health returns a HTTP 406 'Not Acceptable', with the following error in the console:
.c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson serialization for type [class org.springframework.boot.actuate.health.Health]: java.lang.IllegalStateException: Can not override serializer
.w.s.m.s.DefaultHandlerExceptionResolver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: (was java.lang.NullPointerException) (through reference chain: org.springframework.boot.actuate.health.Health["[anySetter]"]->java.util.Collections$UnmodifiableMap["diskSpace"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.springframework.boot.actuate.health.Health["[anySetter]"]->java.util.Collections$UnmodifiableMap["diskSpace"])
start with 'Building a RESTful Web Service' from https://spring.io/guides/gs/rest-service/
add spring-actuator by adding to build.gradle:
compile("org.springframework.boot:spring-boot-starter-actuator")
run and test by visiting http://localhost:8080/health - should see some JSON with health info.
force upgrade to the latest snapshot version of jackson, 2.9.0, by amending build.gradle:
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
exclude group: 'com.fasterxml.jackson.core'
}
testCompile('org.springframework.boot:spring-boot-starter-test')
compile("org.springframework.boot:spring-boot-starter-actuator") {
exclude group: 'com.fasterxml.jackson.core'
}
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.0-20161214.215532-368'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.0-20161209.054204-56'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.0-20161128.053707-86'
}
re-run and see the error by visiting /health
The /greeting endpoint works as before and serializes the 'Greeting' object to JSON.
Thanks for the report, we won't be officially supporting Jackson 2.9 until Spring Boot 1.5.
Looking at the release schedule we're unlikely to support Jackson 2.9 until Spring Boot 2.0
This appears to be a bug in Jackson. I've opened https://github.com/FasterXML/jackson-databind/issues/1559
I see this issue even with jackson 2.9.0.pr1.
I had to use version 2.8.7:
ext {
jacksonVersion = '2.8.7'
}
configurations.all {
resolutionStrategy {
force "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
force "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
force "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
}
}
Most helpful comment
This appears to be a bug in Jackson. I've opened https://github.com/FasterXML/jackson-databind/issues/1559