Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Data Rest 2.4 Intermittent Error (ClassCastException)

Working with Spring Data Rest continues. Moving to 2.4.0 gave me more of the behavior I want, however now I am getting a strange intermittent exception.

About. . . 2/3 of the time when I reload or deploy my application, every SDR endpoint with data throws a 500, and gives the following:

GET /api/departments
--------------------

HTTP Status 500 - 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["departments"]
->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["departments"]
->java.util.ArrayList[0]
->org.springframework.data.rest.webmvc.json.ProjectionResource["content"])

(Full error report available: http://pastebin.com/xzzXkFiR )

Like I said, this does not occur every time I reload/deploy the app, but if it is occuring it's completely stuck, and a reload is the only way to fix it. Very odd behavior, wondering if anyone has any insight.

Issue does not occur if I roll back to Spring Data Rest 2.3.2

Thanks for the help, and please let me know what other relevant information I can provide.

  • SDR: 2.4.1
  • SFW: 4.2.1
  • SDJPA: 1.9.0
Some further testing

Issue also occurs with latest (2.5.0 SNAPSHOT).

like image 549
CollinD Avatar asked Sep 14 '15 19:09

CollinD


2 Answers

I can observe the same issue after updating to Spring Data Rest 2.4.0. The issue is not deterministically reproducible. I do not have any statistics so far, but it occurs less frequently after updating Jackson dependencies from 2.4.0 to 2.6.0. Sometimes it still pops up, but then a reload is sufficient in my case. A minimal example would help to dive deeper into it.

like image 153
Dominik Avatar answered Sep 19 '22 12:09

Dominik


Bugs in jackson-databind library. Upgrade to release train Gosling-SR3 once released.

See https://jira.spring.io/browse/DATAREST-716 and https://jira.spring.io/browse/DATAREST-743

like image 31
jplandrain Avatar answered Sep 19 '22 12:09

jplandrain