-->
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.  [ 2 posts ] 
Author Message
 Post subject: Calls to getCurrentSession() returns a closed session
PostPosted: Sun Feb 22, 2009 5:18 pm 
Beginner
Beginner

Joined: Wed Dec 17, 2008 12:10 pm
Posts: 47
I am using Hibernate 3.3.1GA.

I'm using the OpenSessionInViewFilter, and I'm running in to problems specifically when multiple requests are executed in quick succession. What happens is calls to SessionFactory.getCurrentSession() will return a closed session. Why does this happen?? Why would get current session ever return a closed session. Shouldn't it open a new session when the current session is closed?

To fix this, I added code to my HibernateUtil that would check to see if the session is closed, if so open a new one. The problem is still with quick requests, a few of them will get the "Session is closed!" exception. I'm absolutely baffled. I'm using tomcat, not using JNDI. Is tomcat letting threads get crossed somehow???


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 22, 2009 10:30 pm 
Beginner
Beginner

Joined: Wed Dec 17, 2008 12:10 pm
Posts: 47
I take it back! It was my own problem. I was storing transactions in a static field (I wrote my version of the HibernateUtil when I first started using hibernate and java for that matter). So, obviously when multiple threads were making a request the transactions were getting mixed up.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.