-->
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.  [ 8 posts ] 
Author Message
 Post subject: SessionException: Session was already closed
PostPosted: Fri Jan 11, 2008 6:01 am 
Newbie

Joined: Fri Jan 11, 2008 5:50 am
Posts: 9
Hello,

Does calling commit() or rollback() automatically close the session that you are using? I've checked the doco and it does not mention it, but after issuing a commit (or rollback) I get the following exception:

Code:
org.hibernate.SessionException: Session was already closed
   org.hibernate.impl.SessionImpl.close(SessionImpl.java:275)
   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
   $Proxy2.close(Unknown Source)
com.thinkdesigns.sett.ChargePeriodRegistryHibernate.createChargePeriod(ChargePeriodRegistryHibernate.java:28)


Below is the createChargePeriod function from the ChargePeriodRegistryHibernate class:

Code:
  public long createChargePeriod( ChargePeriodBean chg ) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Long id = (Long) session.save(chg);
   
    session.getTransaction().commit();
    session.close();
   
    return id;
  }


The HibernateUtil class is as follows:

Code:
public class HibernateUtil {

    private static final SessionFactory sessionFactory;

    static {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            sessionFactory = new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}


Many Thanks for your help

Andy


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 12, 2008 3:02 am 
Newbie

Joined: Sat Jan 12, 2008 2:45 am
Posts: 1
This is the article I found:
It is opened when getCurrentSession() is called for the first time, but in a "proxied" state that doesn't allow you to do anything except start a transaction. When the transaction ends, either through commit or roll back, the "current" Session is closed automatically.

http://www.hibernate.org/42.html


Try delete session.close() after the transaction commits.

==============

I also ran into the same problem, but only happens when DEBUGGING. After call getCurrentSession(), the session returns $Proxy1 session closed. But if I add conditional statement as
if (session == null || session.isOpen() == false)... then session will be valid.
Anyone knows what happened??

Thanks....


Top
 Profile  
 
 Post subject: This behavior is inconsistent with code in Hibernate manual
PostPosted: Wed Jul 09, 2008 12:41 am 
Newbie

Joined: Wed Jul 09, 2008 12:32 am
Posts: 1
Location: Los Angeles
I have had the same problem. I don't understand then how this code (from the hibernate manual)http://www.hibernate.org/hib_docs/reference/en/html/transactions.htmlis supposed to work:
Code:
// foo is an instance loaded by a previous Session
foo.setProperty("bar");
session = factory.openSession();
Transaction t = session.beginTransaction();
session.saveOrUpdate(foo); // Use merge() if "foo" might have been loaded already
t.commit();
session.close();

Also, if t.close() closes the session, what is the point of session.close()?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2008 1:53 pm 
Newbie

Joined: Mon Sep 22, 2008 8:45 am
Posts: 5
I have same problem, when I commit transaction I get:

Code:
org.hibernate.SessionException: Session was already closed
   at org.hibernate.impl.SessionImpl.close(SessionImpl.java:275)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
   at $Proxy0.close(Unknown Source)
   at sapi.SCountry.getCountryNames(SCountry.java:44)
   at gui.NewFlightDialog.initGUI(NewFlightDialog.java:109)
   at gui.NewFlightDialog.<init>(NewFlightDialog.java:74)
   at gui.SatSwing.showNewFlightDialog(SatSwing.java:177)
   at gui.SatSwing.access$0(SatSwing.java:176)
   at gui.SatSwing$2.actionPerformed(SatSwing.java:88)
   at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
   at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
   at javax.swing.AbstractButton.doClick(Unknown Source)
   at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
   at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
   at java.awt.Component.processMouseEvent(Unknown Source)
   at javax.swing.JComponent.processMouseEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)


And btw, whatewer I'm doing when I
Code:
sessionFactory = new Configuration().configure(HIBERNATE_CONFIG).buildSessionFactory();

I get:
Code:
24.09.2008. 19.52.28 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.6
24.09.2008. 19.52.28 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
24.09.2008. 19.52.28 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
24.09.2008. 19.52.28 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
24.09.2008. 19.52.28 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: model/hibernate/hibernate.cfg.xml
24.09.2008. 19.52.28 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: model/hibernate/hibernate.cfg.xml
24.09.2008. 19.52.29 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : model/hibernate/Country.hbm.xml
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.hibernate.Country -> country
24.09.2008. 19.52.29 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : model/hibernate/Airport.hbm.xml
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.hibernate.Airport -> airport
24.09.2008. 19.52.29 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : model/hibernate/Flight.hbm.xml
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.hibernate.Flight -> flight
24.09.2008. 19.52.29 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : model/hibernate/Ticket.hbm.xml
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.hibernate.Ticket -> ticket
24.09.2008. 19.52.29 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : model/hibernate/Airplane.hbm.xml
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.hibernate.Airplane -> airplane
24.09.2008. 19.52.29 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.hibernate.Airport.flightsForToId -> flight
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.hibernate.Airport.flightsForFromId -> flight
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.hibernate.Flight.ticketsForReturningId -> ticket
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.hibernate.Flight.ticketsForDepartureId -> ticket
24.09.2008. 19.52.29 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.hibernate.Airplane.flights -> flight
24.09.2008. 19.52.29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
24.09.2008. 19.52.29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
24.09.2008. 19.52.29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
24.09.2008. 19.52.29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost/sat
24.09.2008. 19.52.29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=umpirsky, password=****}
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.51b-community-nt
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.5 ( Revision: ${svn.Revision} )
24.09.2008. 19.52.30 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
24.09.2008. 19.52.30 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
24.09.2008. 19.52.30 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
24.09.2008. 19.52.30 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
24.09.2008. 19.52.30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
24.09.2008. 19.52.30 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
24.09.2008. 19.52.30 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured


Top
 Profile  
 
 Post subject: Re: SessionException: Session was already closed
PostPosted: Thu Jun 04, 2009 4:16 am 
Newbie

Joined: Thu Jun 04, 2009 4:13 am
Posts: 1
seems just like mine

any bright ideas ?


WARNING: On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries
org.hibernate.SessionException: Session is closed!
at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:72)
at org.hibernate.impl.SessionImpl.getPersistenceContext(SessionImpl.java:1850)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromSessionCache(DefaultLoadEventListener.java:475)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:378)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:165)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:207)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:873)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
at org.hibernate.type.EntityType.resolve(EntityType.java:412)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
at org.hibernate.loader.Loader.doQuery(Loader.java:752)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2015)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:59)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:587)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1743)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:476)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:867)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:264)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at com.rocketier.saaccess.datalayer.csDataLayerUtils.getApplicationInstance(csDataLayerUtils.java:100)
at com.rocketier.saaccess.datalayer.csDataLayerUtils.getAppInsatnceAdmin(csDataLayerUtils.java:203)
at com.rocketier.saaccess.businessprocess.services.csUserServices.getAdmin(csUserServices.java:100)
at org.apache.jsp.bugs_jsp._jspService(bugs_jsp.java:193)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
04-Jun-2009 10:49:06 org.hibernate.event.def.DefaultLoadEventListener onLoad
INFO: Error performing load command
org.hibernate.SessionException: Session is closed!
at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:72)
at org.hibernate.impl.SessionImpl.getPersistenceContext(SessionImpl.java:1850)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromSessionCache(DefaultLoadEventListener.java:475)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:378)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:165)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:207)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:873)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
at org.hibernate.type.EntityType.resolve(EntityType.java:412)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
at org.hibernate.loader.Loader.doQuery(Loader.java:752)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2015)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:59)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:587)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1743)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:476)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:867)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:264)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at com.rocketier.saaccess.datalayer.csDataLayerUtils.getApplicationInstance(csDataLayerUtils.java:100)
at com.rocketier.saaccess.datalayer.csDataLayerUtils.getAppInsatnceAdmin(csDataLayerUtils.java:203)
at com.rocketier.saaccess.businessprocess.services.csUserServices.getAdmin(csUserServices.java:100)
at org.apache.jsp.bugs_jsp._jspService(bugs_jsp.java:193)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)


Top
 Profile  
 
 Post subject: Re: SessionException: Session was already closed
PostPosted: Mon Mar 29, 2010 1:37 am 
Newbie

Joined: Thu Dec 03, 2009 4:36 am
Posts: 12
To solve this problem, try using this mehod for opening the session

Session session = HibernateUtil.getSessionFactory().openSession();

instead of

Session session = HibernateUtil.getSessionFactory().getCurrentSession();

If we use the getCurrentSession() method , tansaction.commit() / rollback() closes the connection.

If you are ver particular in using getCurrentSession. Then check whether session.isOpen() is true or false based on that

you can handle the issue


Rajesh Subbiah

_________________
Regards,
Rajesh Subbiah


Top
 Profile  
 
 Post subject: Re: SessionException: Session was already closed
PostPosted: Thu May 06, 2010 9:46 am 
Newbie

Joined: Thu May 06, 2010 9:45 am
Posts: 1
Thank you man....saved me a great deal of trouble :)


Top
 Profile  
 
 Post subject: Re: SessionException: Session was already closed
PostPosted: Thu Jun 24, 2010 4:44 pm 
Newbie

Joined: Thu Jun 24, 2010 4:43 pm
Posts: 1
Same here, thank you !


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