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

Rest Endpoints produce HttpMessageNotWritableException sometimes after restarts [DATAREST-743] #1116

Closed
spring-projects-issues opened this issue Jan 7, 2016 · 3 comments
Assignees
Labels
type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jan 7, 2016

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).

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"])

Affects: 2.4.2 (Gosling SR2)

Reference URL: http://stackoverflow.com/questions/32572525/spring-data-rest-2-4-intermittent-error-classcastexception

Issue Links:

  • DATAREST-716 Rest Endpoints produce HttpMessageNotWritableException sometimes after restarts

Referenced from: commits a8f271a, 88c97a6

Backported to: 2.4.4 (Gosling SR4)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 7, 2016

Oliver Drotbohm commented

Looks like we really have to implement UnwrappingSerializer. I'll get right to it

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 7, 2016

Oliver Drotbohm commented

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.

Feel free to give the snapshots a try!

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 8, 2016

Collin Brown commented

Great! Thank you for the quick turn-around!

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

No branches or pull requests

2 participants