views:

618

answers:

3

Hi,

When I call the method session.begin transaction as follows:

//session factory is instantiated via a bean
Session session = this.getSessionFactory().getCurrentSession();
session.beginTransaction();

Then I get the following exception message

6:13:52,217 ERROR [STDERR] org.hibernate.SessionException: Session is closed!
at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1319)

What could be the cause of this error ?

+5  A: 

Update: I guess that calling getCurrentSession() does not guarantee that the session is actually open. For the very first time, you should use

Session session = this.getSessionFactory().openSession();
session.beginTransaction();

instead. This suggestion is actually consistent with the page you found.

Earlier:

Based on the information available so far, we can conclude that the cause of the error is the session not being open ;-)

Péter Török
+1 Agree completely.
Padmarag
A: 

The cause could be global warming :)

Padmarag
+1  A: 

I think I found the answer in:

Session is Closed

I am yet to implement it

Anand
Glad you solved the mystery.
Padmarag

related questions