-->
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.  [ 1 post ] 
Author Message
 Post subject: LazyInitializationException with objects from L2 cache
PostPosted: Tue Apr 20, 2010 1:02 pm 
Newbie

Joined: Tue Apr 20, 2010 1:01 pm
Posts: 1
I am getting the following exception working with hibernate:

org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at com.benefitpoint.cmp.security.Permission$$EnhancerByCGLIB$$15036d4c.hashCode(<generated>)
at java.util.HashMap.hash(HashMap.java:261)
at java.util.HashMap.containsKey(HashMap.java:339)
at java.util.HashSet.contains(HashSet.java:180)

This doesn’t happen every time I access this particular page. I have narrowed it down to the following scenario:

• Request A retrieves objects from hibernate. The objects include lazy loaded collections and object graphs which are not full navigated and therefore only partially realized.
• Request A results in those same objects being stored in the L2 cache (ehcache)
• Request B retrieves objects from hibernate. The objects retrieved include some of the same objects stored in L2 cache from request A.
• When request B navigates to those objects which are not realized from the previous process, the exception above is thrown.

As I debug, it looks like the proxied set in these not realized objects has a reference to a session which is closed. I set debug points on the session impl and did not see a preceeding close in the request. It seems to me that this session reference is a stale reference from Request A (?). To complicate matters, the application makes use of hibernate is some non-standard ways. Request A does not use the OpenSessionInViewFilter, Request B does. Request A uses more manual hibernate processing whereas Request B uses a more standard spring stack.

My questions:

• Does hibernate support storing non-realized lazy objects in the L2 cache for future use by a different session?
• Is this likely an issue with a mis-configuration of hibernate in the application?

My environment:

Hibernate 3.0.5
Spring 1.2.7
JDK 1.4.2
Ehcache 1.1


Thanks in advance.

Ben


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

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.