Occasionally, the application throws a HttpMessageNotWritableException on start up. See #DATAREST-716. It appears this is still happening in Gosling SR2 (Spring Boot 1.3.1).
2016-01-06 19:27:54.639 INFO 1783 --- [ost-startStop-1] o.a.catalina.util.SessionIdGenerator : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [9,898] milliseconds.
Jan 06, 2016 7:27:54 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 06, 2016 7:27:54 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 06, 2016 7:27:54 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 59514 ms
Jan 06, 2016 7:27:54 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-01-06 19:27:54.817 INFO 1783 --- [bio-8080-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2016-01-06 19:27:54.854 INFO 1783 --- [bio-8080-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 28 ms
2016-01-06 19:27:58.029 WARN 1783 --- [io-8080-exec-11] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$ProjectionResourceContentSerializer cannot be cast to com.fasterxml.jackson.databind.ser.impl.UnwrappingBeanSerializer (through reference chain: org.springframework.hateoas.PagedResources["_embedded"]->java.util.UnmodifiableMap["activities"]->java.util.ArrayList[0]->org.springframework.data.rest.webmvc.json.ProjectionResource["content"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$ProjectionResourceContentSerializer cannot be cast to com.fasterxml.jackson.databind.ser.impl.UnwrappingBeanSerializer (through reference chain: org.springframework.hateoas.PagedResources["_embedded"]->java.util.UnmodifiableMap["activities"]->java.util.ArrayList[0]->org.springframework.data.rest.webmvc.json.ProjectionResource["content"])
This should be fixed in master and the bugfix branch for Gosling. In the fix for DATAREST-716 I missed ProjectionResourceContentSerializer which suffered from the same mutability problem as ProjectionSerializer. This should be fixed now so that the instances don't get mutated anymore and the suspicious code path casting the instance to UnwrappingBeanSerializer shouldn't actually be triggered anymore as the unwrapping instances are just created on the fly while the default ones (which get tested by that code path) remain non-unwrapping.
Collin Brown opened DATAREST-743 and commented
Occasionally, the application throws a HttpMessageNotWritableException on start up. See #DATAREST-716. It appears this is still happening in Gosling SR2 (Spring Boot 1.3.1).
Affects: 2.4.2 (Gosling SR2)
Reference URL: http://stackoverflow.com/questions/32572525/spring-data-rest-2-4-intermittent-error-classcastexception
Issue Links:
Referenced from: commits a8f271a, 88c97a6
Backported to: 2.4.4 (Gosling SR4)
The text was updated successfully, but these errors were encountered: