-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Hibernate+Jersey:no serializer for JavassistLazyInitializer
PostPosted: Wed Mar 30, 2011 7:20 pm 
Newbie

Joined: Sun Feb 27, 2011 1:19 pm
Posts: 4
Hello together,

i use hibernate3 (bundle) in a servlet.
Before a webservice function is closed, the lazyloaded values location in user shall be initilized with
Code:
Hibernate.initialize(rideSearch.locationStart);


hibernate correctly calls the database access, however the object is still refered to javassistLazyInitializer(id=190). Trying to marshalling it creates the error:
Code:
31.03.2011 01:12:14 org.apache.catalina.core.StandardWrapperValve invoke
SCHWERWIEGEND: Servlet.service() for servlet *** Web Service threw exception
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.***ReturnSearch["rideSearch"]->de***RideSearch["user"]->de***model.User_$$_javassist_1["handler"])


When Hibernate.initialize is called the "variables" in eclipse show the following change:
* user.location.handler changes from false to true
* user.location.handler.target is correctly filled with all the data

For some reason the actuall java class is not filled with the data of user.location.handler.target though. Could anybody give me a hint?

Thank you very much!!


Last edited by Steve Eastwood on Thu Mar 31, 2011 8:22 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [lazy load] initialize: loads values only in target
PostPosted: Thu Mar 31, 2011 3:39 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Hibernate can not replace the proxy-object when initializing it, as you could have other pointers to that object. If you want it to be of your entity-class and not a subclass you need to fetch it eagerly.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: Re: [lazy load] initialize: loads values only in target
PostPosted: Thu Mar 31, 2011 8:20 pm 
Newbie

Joined: Sun Feb 27, 2011 1:19 pm
Posts: 4
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.

I found two other solutions, which i both don't work (yet).

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.