users@jersey.java.net

[Jersey] Jersey + Hibernate + lazyLoad: No serializer for JavassistLazyInitializer

From: Peff <peff_at_gmx.at>
Date: Thu, 31 Mar 2011 15:28:06 -0700 (PDT)

Hello together,

When Jersey tries to serialize my the lazyloaded parts of my returned class
it throws the following errorr:
org.codehaus.jackson.map.JsonMappingException: No serializer found for class
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no
properties discovered to create BeanSerializer (to avoid exception, disable
SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain:
de.**.web.util.ReturnSearch["rideSearch"]->de.**.web.util.RideSearch["user"]->de.**.model.User_$$_javassist_1["handler"])

None of the solutions I found worked:

1. jackson-module-hibernate
(https://github.com/FasterXML/jackson-module-hibernate)
this seems to cover exactly what i am looking for. The instructions to
register the ObjectMapper are only for Spring and i did not found a
possibility how to do this in Jersey. Can anybody help me with that?

2. Many answers only simply propose to use eager fetchting or HQL. Since
dynamicly complex data is loaded which then is put into a new model, this
approach is very complex to realise. If this needs to be done, i don't see
an advantage of hibernate anymore.

3. In some cases it seems that this error is produced by a circular
reference (http://forum.springsource.org/showthread.php?t=98764). I
doublechecked this. In my case there is no circular reference.


Can anybody give me a hint or share a link. I'm pretty stuck.

Thank you very much!

--
View this message in context: http://jersey.576304.n2.nabble.com/Jersey-Hibernate-lazyLoad-No-serializer-for-JavassistLazyInitializer-tp6228887p6228887.html
Sent from the Jersey mailing list archive at Nabble.com.