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

Exception thrown when attempting to fetch null relationship on lazy loaded DBRef [DATAREST-359] #741

Open
spring-projects-issues opened this issue Jul 22, 2014 · 20 comments
Assignees
Labels
type: bug A general bug

Comments

@spring-projects-issues
Copy link

Aaron Loes opened DATAREST-359 and commented

This appears to be an issue with using SD Rest with SD MongoDB and lazy DBRefs.

Given my Farmer class:

// this is required for lazy loading as for it to work, SD Rest must use getter methods and not field access.
@AccessType(AccessType.Type.PROPERTY) 
public class Farmer extends PersistentEntity {
	private String firstName;
	
	private String lastName;
	
	@DBRef(lazy = true)
	private Farmer spouse;

	/* ... getters/setter */
}

And when creating an instance of a farmer:

{
  "firstName" : "Aaron",
  "lastName" : "Loes"
}
{
  "version" : 0,
  "createdBy" : null,
  "createdDate" : null,
  "lastModifiedBy" : null,
  "lastModifiedDate" : null,
  "firstName" : "Aaron",
  "lastName" : "Loes",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/spring-data-rest-mongo-couchbase-prototype/api/farmers/53ce7a6fab789b1fd8bba7b1"
    },
    "spouse" : {
      "href" : "http://localhost:8080/spring-data-rest-mongo-couchbase-prototype/api/farmers/53ce7a6fab789b1fd8bba7b1/spouse"
    }
  }
}

All is well until i try to get the farmers spouse:

{"cause":null,"message":"Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"}

and this is the exception thrown:

10:00:42.365 [http-bio-8080-exec-8] ERROR o.s.d.r.w.AbstractRepositoryRestController - Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable
java.lang.IllegalArgumentException: Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable
	at org.springframework.util.Assert.isInstanceOf(Assert.java:337) ~[spring-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.data.rest.webmvc.support.RepositoryEntityLinks.linkToSingleResource(RepositoryEntityLinks.java:147) ~[spring-data-rest-webmvc-2.1.1.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.getSelfLinkFor(PersistentEntityResourceAssembler.java:88) ~[spring-data-rest-webmvc-2.1.1.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:64) ~[spring-data-rest-webmvc-2.1.1.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController$1.apply(RepositoryPropertyReferenceController.java:141) ~[spring-data-rest-webmvc-2.1.1.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController$1.apply(RepositoryPropertyReferenceController.java:110) ~[spring-data-rest-webmvc-2.1.1.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController.doWithReferencedProperty(RepositoryPropertyReferenceController.java:464) ~[spring-data-rest-webmvc-2.1.1.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController.followPropertyReference(RepositoryPropertyReferenceController.java:148) ~[spring-data-rest-webmvc-2.1.1.RELEASE.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_25]
	at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
	at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) ~[spring-web-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) ~[spring-web-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) ~[spring-webmvc-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) ~[spring-webmvc-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:685) ~[spring-webmvc-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) ~[spring-webmvc-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919) ~[spring-webmvc-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851) ~[spring-webmvc-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953) ~[spring-webmvc-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844) ~[spring-webmvc-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) [servlet-api.jar:na]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829) ~[spring-webmvc-3.2.10.RELEASE.jar:3.2.10.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) [servlet-api.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [catalina.jar:7.0.27]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.27]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) [catalina.jar:7.0.27]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) [catalina.jar:7.0.27]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) [catalina.jar:7.0.27]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) [catalina.jar:7.0.27]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) [catalina.jar:7.0.27]
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) [catalina.jar:7.0.27]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.27]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) [catalina.jar:7.0.27]
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999) [tomcat-coyote.jar:7.0.27]
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) [tomcat-coyote.jar:7.0.27]
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) [tomcat-coyote.jar:7.0.27]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_25]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_25]
	at java.lang.Thread.run(Thread.java:724) [na:1.7.0_25]

It was expected a 404 would have been returned. This does not happen when we are not lazy loading relationships


Attachments:

4 votes, 9 watchers

@spring-projects-issues
Copy link
Author

Aaron Loes commented

using spring-data-mongo version 1.5.1.RELEASE and spring-data-rest-webmvc version 2.1.1.RELEASE

@spring-projects-issues
Copy link
Author

Sri commented

same issue is already raised - DATAREST-310. However good job on adding details

@spring-projects-issues
Copy link
Author

Gary Frankel commented

Dont know whether this needs to be a different request.....

Using Spring Data MongoDB (1.6.1 or 1.6.2) and spring-boot-starter-web 1.2.1 and spring-data-rest-webmvc 2.2.1, I see a very similar issue. Ran into because I'm working on a different database that also has lazy loading and wanted to see what the Mongo implementation does. Yes, the ID is initialized on the proxy... BUT as we go all the way through to creating a return value, eventually, we get the JSON exception shown below....

I was wrong on my initial comment - not due to the Lazy Loader not being called...
The BeanSerializerFactory creates a serializer for the Proxy for the Address type. It works from the bean description for that proxy - which includes a property based on "getCallbacks". When the code later tries to do the serialization - it finds a registered callback which is the LazyLoadingInterceptor - which it fails to serialize since it is "empty". I suspect that this can be solved by telling the serialization to ignore empty beans, but is that really the right answer?

Now, seems like this would have come up before - I did try setting @AccessType(AccessType.Type.PROPERTY) and also tried @AccessType(AccessType.Type.FIELD)... didnt seem to matter

BUT maybe the code is supposed to get rid of the Proxy before calling all the writers/serializers so that it never hits this serializer for a proxy class ??

Not surprisingly, the same thing happens when I do a Projection that causes the Address to be embedded into the feed for /people.

"Could not write content: No serializer found for class org.springframework.data.mongodb.core.convert.DefaultDbRefResolver$LazyLoadingInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )

Daemon Thread [http-nio-8080-exec-1] (Suspended (exception JsonMappingException))
owns: NioChannel (id=84)
UnknownSerializer.failForEmpty(Object) line: 59
UnknownSerializer.serialize(Object, JsonGenerator, SerializerProvider) line: 26
ObjectArraySerializer.serializeContents(Object[], JsonGenerator, SerializerProvider) line: 228
ObjectArraySerializer.serializeContents(Object, JsonGenerator, SerializerProvider) line: 25
ObjectArraySerializer(ArraySerializerBase<T>).serialize(T, JsonGenerator, SerializerProvider) line: 57
BeanPropertyWriter.serializeAsField(Object, JsonGenerator, SerializerProvider) line: 505
UnwrappingBeanSerializer(BeanSerializerBase).serializeFields(Object, JsonGenerator, SerializerProvider) line: 639
UnwrappingBeanSerializer.serialize(Object, JsonGenerator, SerializerProvider) line: 118
UnwrappingBeanPropertyWriter.serializeAsField(Object, JsonGenerator, SerializerProvider) line: 112
BeanSerializer(BeanSerializerBase).serializeFields(Object, JsonGenerator, SerializerProvider) line: 639
BeanSerializer.serialize(Object, JsonGenerator, SerializerProvider) line: 152
DefaultSerializerProvider$Impl(SerializerProvider).defaultSerializeValue(Object, JsonGenerator) line: 896
PersistentEntityJackson2Module$PersistentEntityResourceSerializer.serialize(PersistentEntityResource, JsonGenerator, SerializerProvider) line: 181
PersistentEntityJackson2Module$PersistentEntityResourceSerializer.serialize(Object, JsonGenerator, SerializerProvider) line: 117
DefaultSerializerProvider$Impl(DefaultSerializerProvider).serializeValue(JsonGenerator, Object) line: 128
ObjectMapper.writeValue(JsonGenerator, Object) line: 1902
TypeConstrainedMappingJackson2HttpMessageConverter(AbstractJackson2HttpMessageConverter).writeInternal(Object, HttpOutputMessage) line: 231
TypeConstrainedMappingJackson2HttpMessageConverter(AbstractHttpMessageConverter<T>).write(T, MediaType, HttpOutputMessage) line: 208
HttpEntityMethodProcessor(AbstractMessageConverterMethodProcessor).writeWithMessageConverters(T, MethodParameter, ServletServerHttpRequest, ServletServerHttpResponse) line: 161
HttpEntityMethodProcessor.handleReturnValue(Object, MethodParameter, ModelAndViewContainer, NativeWebRequest) line: 144
HandlerMethodReturnValueHandlerComposite.handleReturnValue(Object, MethodParameter, ModelAndViewContainer, NativeWebRequest) line: 71
ResourceProcessorHandlerMethodReturnValueHandler.handleReturnValue(Object, MethodParameter, ModelAndViewContainer, NativeWebRequest) line: 172
HandlerMethodReturnValueHandlerComposite.handleReturnValue(Object, MethodParameter, ModelAndViewContainer, NativeWebRequest) line: 71
ServletInvocableHandlerMethod.invokeAndHandle(ServletWebRequest, ModelAndViewContainer, Object...) line: 126
RepositoryRestHandlerAdapter(RequestMappingHandlerAdapter).invokeHandleMethod(HttpServletRequest, HttpServletResponse, HandlerMethod) line: 777
RepositoryRestHandlerAdapter(RequestMappingHandlerAdapter).handleInternal(HttpServletRequest, HttpServletResponse, HandlerMethod) line: 706
RepositoryRestHandlerAdapter(AbstractHandlerMethodAdapter).handle(HttpServletRequest, HttpServletResponse, Object) line: 85
DispatcherServlet.doDispatch(HttpServletRequest, HttpServletResponse) line: 943
DispatcherServlet.doService(HttpServletRequest, HttpServletResponse) line: 877
DispatcherServlet(FrameworkServlet).processRequest(HttpServletRequest, HttpServletResponse) line: 966
DispatcherServlet(FrameworkServlet).doGet(HttpServletRequest, HttpServletResponse) line: 857
DispatcherServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 618
DispatcherServlet(FrameworkServlet).service(HttpServletRequest, HttpServletResponse) line: 842
DispatcherServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 725
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 291
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
HiddenHttpMethodFilter.doFilterInternal(HttpServletRequest, HttpServletResponse, FilterChain) line: 77
HiddenHttpMethodFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 107
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 239
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
OrderedCharacterEncodingFilter(CharacterEncodingFilter).doFilterInternal(HttpServletRequest, HttpServletResponse, FilterChain) line: 88
OrderedCharacterEncodingFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 107
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 239
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
StandardWrapperValve.invoke(Request, Response) line: 219
StandardContextValve.invoke(Request, Response) line: 106
NonLoginAuthenticator(AuthenticatorBase).invoke(Request, Response) line: 501
StandardHostValve.invoke(Request, Response) line: 142
ErrorReportValve.invoke(Request, Response) line: 79
StandardEngineValve.invoke(Request, Response) line: 88
CoyoteAdapter.service(Request, Response) line: 537
Http11NioProcessor(AbstractHttp11Processor<S>).process(SocketWrapper<S>) line: 1085
Http11NioProtocol$Http11ConnectionHandler(AbstractProtocol$AbstractConnectionHandler<S,P>).process(SocketWrapper<S>, SocketStatus) line: 658
Http11NioProtocol$Http11ConnectionHandler.process(SocketWrapper<NioChannel>, SocketStatus) line: 222
NioEndpoint$SocketProcessor.doRun(SelectionKey, NioEndpoint$KeyAttachment) line: 1556
NioEndpoint$SocketProcessor.run() line: 1513
ThreadPoolExecutor(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: 1145
ThreadPoolExecutor$Worker.run() line: 615
TaskThread$WrappingRunnable.run() line: 61
TaskThread(Thread).run() line: 744

@spring-projects-issues
Copy link
Author

Caleb Cushing commented

java.lang.IllegalArgumentException: Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable

I've seen this same issue with Hibernate, I was about to report it.

@spring-projects-issues
Copy link
Author

Caleb Cushing commented

this tarball contains a repo showing this same error with hibernate. There is uncommitted change from lazy to eager that fixes the problem.

curl -X POST -H 'Content-Type: application/json' -d '{"title":"P1", "description":"First project"}' http://localhost:8080/projects
curl -X POST -H 'Content-Type: application/json' -d '{"title":"T1", "description":"First task", "project":"http://localhost:8080/projects/1"}' http://localhost:8080/tasks
curl -X GET http://localhost:8080/tasks/1/project

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

I just ran mvn clean test on the provided sample and it doesn't fail for me. I also ran the project (i.e. mvn spring-boot:run) and executed the statements as given and got this:

collabify @ master $ curl -X POST -H 'Content-Type: application/json' -d '{"title":"P1", "description":"First project"}' http://localhost:8080/projects
collabify @ master $ curl -X POST -H 'Content-Type: application/json' -d '{"title":"T1", "description":"First task", "project":"http://localhost:8080/projects/1"}' http://localhost:8080/tasks
collabify @ master $ curl -X GET http://localhost:8080/tasks/1/project
{
  "title" : "P1",
  "description" : "First project",
  "new" : false,
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/projects/1"
    },
    "tasks" : {
      "href" : "http://localhost:8080/projects/1/tasks"
    }
  }
}

Generally speaking: would you guys mind trying more recent versions of Spring Data REST than the ones? Spring Boot 1.2.5 is on Evans SR1 (Dec 2014), which is pretty dated and the subsequent versions (Evans current service release is SR3 - Jul 2015, Fowler SR2 (Jul 2015), Gosling GA (Sep 2015)

@spring-projects-issues
Copy link
Author

Caleb Cushing commented

just ran mvn clean test on the provided sample and it doesn't fail for me.

yeah tests don't fail, but did you remove the "uncommitted change to eager"? a ```
git stash



 > would you guys mind trying more recent versions of Spring Data REST than the ones? Spring Boot 1.2.5

Yeah I can give it a try, though curated dependencies... I guess I'll go try to figure out what versions are needed (seeing as how I can't put Gosling GA in a pom)

@spring-projects-issues
Copy link
Author

Caleb Cushing commented

Having trouble upgrading, I added this to <properties> in the pom

<spring-data-releasetrain.version>Gosling-RELEASE</spring-data-releasetrain.version>
<spring-hateoas.version>0.19.0.RELEASE</spring-hateoas.version>

but now I get this error

 curl -X POST -H 'Content-Type: application/json' -d '{"title":"P1", "description":"First project"}' http://localhost:8080/projects
{"timestamp":1441629749653,"status":500,"error":"Internal Server Error","exception":"java.lang.AbstractMethodError","message":"com.fasterxml.jackson.databind.JsonSerializer.isEmpty(Ljava/lang/Object;)Z","path":"/projects"}%

@spring-projects-issues
Copy link
Author

Caleb Cushing commented

I removed the patch for eager, as mentioned I've been unsuccessful in upgrading, the instructrions in http://spring.io/blog/2015/09/01/spring-data-release-train-gosling-goes-ga seem incomplete.

collabify  % curl -X POST -H 'Content-Type: application/json' -d '{"title":"P1", "description":"First project"}' http://localhost:8080/projects
collabify  % curl -X POST -H 'Content-Type: application/json' -d '{"title":"T1", "description":"First task", "project":"http://localhost:8080/projects/1"}' http://localhost:8080/tasks
collabify  % curl -X GET http://localhost:8080/tasks/1/project                                                             slave-vi
{"cause":null,"message":"Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"}%  

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

The upgrade to Gosling also requires an upgrade of Jackson to 2.5 or better (I just added that to the blog post). Alternatively just switch to Spring Boot 1.3 M5 as it ships all libraries in the required versions

@spring-projects-issues
Copy link
Author

Caleb Cushing commented

all that was updated in the current tarball was

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.M5</version>
</parent>
collabify  % curl -X POST -H 'Content-Type: application/json' -d '{"title":"P1", "description":"First project"}' http://localhost:8080/projects
{
  "title" : "P1",
  "description" : "First project",
  "new" : false,
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/projects/1"
    },
    "project" : {
      "href" : "http://localhost:8080/projects/1"
    },
    "tasks" : {
      "href" : "http://localhost:8080/projects/1/tasks"
    }
  }
}%                                                                                                        collabify  % curl -X POST -H 'Content-Type: application/json' -d '{"title":"T1", "description":"First task", "project":"http://localhost:8080/projects/1"}' http://localhost:8080/tasks
{
  "title" : "T1",
  "description" : "First task",
  "new" : false,
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/tasks/1"
    },
    "task" : {
      "href" : "http://localhost:8080/tasks/1"
    },
    "project" : {
      "href" : "http://localhost:8080/tasks/1/project"
    }
  }
}%                                                                                                        collabify  % curl -X GET http://localhost:8080/tasks/1/project                                   slave-vi
{"timestamp":1441636713413,"status":500,"error":"Internal Server Error","exception":"org.springframework.http.converter.HttpMessageNotWritableException","message":"Could not write content: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: org.springframework.data.rest.webmvc.json.[\"content\"]->com.wautco.collabify.domain.Project_$$_jvstc40_0[\"handler\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: org.springframework.data.rest.webmvc.json.[\"content\"]->com.wautco.collabify.domain.Project_$$_jvstc40_0[\"handler\"])","path":"/tasks/1/project"}%       

also this new exception doesn't appear to be getting logged

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

So let's please take a step back. I am a bit lost in all the samples you post. Would you mind just providing a sample that reproduces the error with a simple mvn clean test?

@spring-projects-issues
Copy link
Author

Caleb Cushing commented

attaching sample with test, there are 2 branches in this tarball, one uses Spring Boot 1.2.5, the other 1.3.0.M5. both fail mvn clean test

@spring-projects-issues
Copy link
Author

Petar Tahchiev commented

I can confirm the same error happens with Hopper-SNAPSHOT :(

@spring-projects-issues
Copy link
Author

Petar Tahchiev commented

I'm sorry for the noise - I have upgraded to Hibernate 5.2 with jackson-datatype-hibernate5 and that's why the error came. When I downgrade to hibernate 5.1 and jackson-datatype-hibernate5 it all works fine

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

I am puzzled. Did you intend to comment another ticket? This one is about MongoDB, not JPA

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

I can see the sample working when I upgrade to Spring Boot 1.3.7 and add the Hibernate Jackson integration

@spring-projects-issues
Copy link
Author

Petar Tahchiev commented

It happens with JPA too. I saw this one:

https://jira.spring.io/browse/DATAJPA-630

and there it was recommended to open it in DATAREST. I have commented on the jackson-datatype-hibernate:

FasterXML/jackson-datatype-hibernate#92

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

To be completely honest I don't care much about issues introduced in Hibernate 5.2. Actually, the release breaking so many things so horribly is the reason that Boot 1.4 ships 5.0 out of the box. That said, — again — the sample provided works on Boot 1.3.7 (Gosling SR4). Whenever you customize persistence provider versions beyond that, be prepared to run into issues.

Inclined to close this as fixed against Gosling SR4, as it's the version I can see the previously failing example work on

@spring-projects-issues
Copy link
Author

Casey Link commented

I'm experiencing this issue with spring data jpa, specifically this issue when fetching a relationship like so:

GET http://localhost:808/api/parent/XX/child

{"cause":null,"message":"Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"}

This ticket isn't related to JPA as you said, but I am hesitant to open another issue, if one exists please point me in that direction.

I'm using:

  • java 8
  • Spring Boot v1.4.2.RELEASE
  • spring-data-releasetrain.version Hopper-SR5
  • Hibernate 5.2.4.Final

A related question, I need to specify my hibernate version explicitly in order to pin some other non-spring packages. I want to use the latest supported/recommended hibernate version from spring-data. Where do I go to find out what version this is?

Looking at the compile dependencies section of spring-data-jpa it looks like hibernate 5.2.4 is supported.

edit: updated to latest versions of hopper release train and boot, same results

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

No branches or pull requests

2 participants