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 ?
Update: I guess that calling
getCurrentSession()does not guarantee that the session is actually open. For the very first time, you should useinstead. 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 😉