Hibernate version: 2.1.7
We are trying to determine how a cached object is reassociated to a session and given a proxy and CGLIBLazyInitializer.
When cached objects are concurrently accessed, we occasionally have the error: Session was closed, or Session is closed.
We have done extensive logging on the sessionImpl object to see its history. The relevant bit is pasted below. The error occurs because the proxy for an object fetched from the cache is part of a session that is being used by another thread. The owning thread closes the session before the new thread is done using the proxy, hence the error.
We know that the object is not being held anywhere except the hibernate cache between requests. So my question is how the proxy gets created for an object fetched from the cache. I have looked at the source but I'm still trying to figure out how all the CGLIB pieces fit together. We are certain that the thread that gets the error is passed the correct session in all hibernate calls from our code.
// Session creation and assignment on thread 8
TP-Processor8 : net.sf.hibernate.impl.SessionImpl@664e93 - Constructor for session: net.sf.hibernate.impl.SessionImpl@664e93 on thread : TP-Processor8
, TP-Processor8 : net.sf.hibernate.impl.SessionImpl@664e93 - opened session
, TP-Processor8 : net.sf.hibernate.impl.SessionImpl@664e93 - TP-Processor8 assigned: net.sf.hibernate.impl.SessionImpl@664e93 SpringSessionFactoryUtils ln 348
// getProxy call and CGLIBLI created on thread 8 for guild#109201
, TP-Processor8 : net.sf.hibernate.impl.SessionImpl@664e93 - getProxy called - persistentClassclass com.sony.soe.guilds.model.Guild : id = 109201
, TP-Processor8 : net.sf.hibernate.impl.SessionImpl@664e93 - CGLIBLazyInitializer created : net.sf.hibernate.proxy.CGLIBLazyInitializer@ecdbe8
// Thread 7 adds guild#109201 as entry to the session associated to thread 8
// why is there no new getProxy call? or added to the right session?
,TP-Processor7 : net.sf.hibernate.impl.SessionImpl@664e93 - WRONG THREAD, this session belongs to: TP-Processor8
, TP-Processor7 : net.sf.hibernate.impl.SessionImpl@664e93 - Entry added : com.sony.soe.guilds.model.Guild@10f2e02 : id= 109201
, TP-Processor7 : net.sf.hibernate.impl.SessionImpl@664e93 - WRONG THREAD, this session belongs to: TP-Processor8
, TP-Processor7 : net.sf.hibernate.impl.SessionImpl@664e93 - getProxy called - persistentClassclass com.sony.soe.guilds.model.GuildAgg : id = 109201
, TP-Processor7 : net.sf.hibernate.impl.SessionImpl@664e93 - WRONG THREAD, this session belongs to: TP-Processor8
, TP-Processor7 : net.sf.hibernate.impl.SessionImpl@664e93 - CGLIBLazyInitializer created : net.sf.hibernate.proxy.CGLIBLazyInitializer@15dddf2
, TP-Processor8 : net.sf.hibernate.impl.SessionImpl@664e93 - initializing non-lazy collections
, TP-Processor8 : net.sf.hibernate.impl.SessionImpl@664e93 - disconnecting session
, TP-Processor8 : net.sf.hibernate.impl.SessionImpl@664e93 - transaction completion
...Errors here when Thread 7 tries to access the session. it has been closed.
|