-->
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.  [ 11 posts ] 
Author Message
 Post subject: getCurrentSession() return a closed session
PostPosted: Mon Nov 28, 2005 12:59 pm 
Newbie

Joined: Fri Nov 25, 2005 5:40 am
Posts: 4
Hello

We are working with EJB, CMT (Container Manager Transaction) WebSphere and Hibernate 3.0.5, when we use getCurrentSession() we get a closed session and this not correct. In not CMT enviroment we can get another session with openSession(), but with CMT and getCurrentSession() how can ask for another session and link to current Transaction JTA?

Regards

Rafa.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 1:21 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 3:56 am 
Newbie

Joined: Fri Nov 25, 2005 5:40 am
Posts: 4
Hello

Thank you, but this article not indicate why sometimes getCurretnSession returns a closed session.


Regards


Rafa.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 3:57 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
How should we know? You ignored this:

http://www.hibernate.org/ForumMailingli ... AskForHelp


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 7:30 am 
Newbie

Joined: Fri Nov 25, 2005 5:40 am
Posts: 4
Hello.

This is the information that I believe is necessary.

We are working with RAD (IBM Rational Software Development Platform) and the Aplicattion Server is Websphere 6.0,
we use EJB 2 and Stateless sessions beans with CMT (Container Manager Transaction.
The problem is when we use getCurrentSession() we get a closed session. This is the code:


private static Session getSesionHibernate() {
if(sessionFactory==null)
throw new HibernateException("Hibernate no ha sido inicializado con un SessionFactory");
Session ses = sessionFactory.getCurrentSession(); // Here it returns a closed session
return ses;
}



The configuration's file is:

hibernate.show_sql true
hibernate.dialect org.hibernate.dialect.DB2Dialect
hibernate.connection.datasource java:comp/env/pooldb2
hibernate.connection.release_mode auto
hibernate.cache.provider_class org.hibernate.cache.NoCacheProvider
hibernate.cache.use_second_level_cache false
hibernate.cache.use_query_cache false
hibernate.transaction.factory_class org.hibernate.transaction.CMTTransactionFactory
hibernate.transaction.manager_lookup_class org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
hibernate.transaction.flush_before_completion true
hibernate.transaction.auto_close_session true
hibernate.current_session_context_class jta


It happens when we are debugging with RAD and Websphere
(we don't know if this happens in another environment different that RAD and Websphere)

When getCurerentSession return a closed session, how can we create a new session and associate it again to the transaccción JTA?

Regards


Rafa.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 7:53 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
"When getCurerentSession return a closed session, how can we create a new session and associate it again to the transaccción JTA? "

You or container must start transaction, "getCurerentSession" associates it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 8:30 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
1. Have you tried with 3.1?
2. Did you create a DEBUG log?
3. Did you check the DEBUG log?
4. Are you sure your code is called inside an ongoing JTA transaction?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 8:32 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Have you tried changing any of the session-related hibernate properties? e.g.

hibernate.connection.release_mode auto
hibernate.transaction.flush_before_completion true
hibernate.transaction.auto_close_session true

While those -should- work as you have written them, without more detail you need you help narrow down the scope of the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 1:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
did your code explicitly close the session?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 1:54 pm 
Newbie

Joined: Fri Nov 25, 2005 5:40 am
Posts: 4
No, the code doesn't close the session explicitly. It is responsibility of the Container (CMT).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 2:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
well, the same mechanism that is used to automatically close the session in this case (a Synchronization) also clears the session from the context.

Meaning that if the CMT forces the session to automatically close the session, that session *will* be removed from the context.

Sorry, the only way I see this happening is by application code explicitly calling Session.close().


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