I am loading a class with reflection (Class.forName())
Then inside its ctor (which i called with newInstance() method), I try to use
sessionFactory.getCurrentSession();
But when i start using the session i get, it throws the following exception:
Code:
org.hibernate.SessionException: Session is closed!
at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
at org.hibernate.impl.SessionImpl.getPersistenceContext(SessionImpl.java:1823)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:877)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:865)
at org.hibernate.loader.Loader.doQuery(Loader.java:729)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
Any idea why after loading the class by reflection it fail to find the current session, or what should i do in this case.
I tried to open another session, but that just causes more problems later, when it says same collection tries to be used by 2 sessions.....
Please help