javax.persistence.PersistenceException: org.hibernate.SessionException: Session is closed!

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Administrator Guide
    via by Unknown author,
  • 2.2.2. FAQs of database configuration
    via by Unknown author,
  • I got an exception as the summary. I add some related debug information and stack trace at the end. I am using a JTA EntityManager associated with current container managed transaction in a J2EE server. This happends when the stateless session bean finishs its excution. When current transaction commits, the current Session is closed by CacheSynchronization class. Then AbstractEntityManagerImpl$1.afterCompletion() method is called. this method trys to get transaction in the closed session object and causes the exception. 14:09:48 DEBUG AbstractFlushingEventListener - executing flush 14:09:48 DEBUG AbstractFlushingEventListener - post flush 14:09:48 DEBUG CacheSynchronization - transaction after completion callback, status: 3 14:09:48 DEBUG SessionImpl - after transaction completion 14:09:48 DEBUG CacheSynchronization - automatically closing session 14:09:48 DEBUG SessionImpl - automatically closing session 14:10:10 DEBUG SessionImpl - closing session org.hibernate.SessionException: Session is closed! at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49) at org.hibernate.impl.SessionImpl.getTransaction(SessionImpl.java:1281) at org.hibernate.ejb.AbstractEntityManagerImpl$1.afterCompletion(AbstractEntityManagerImpl.java:496) at com.evermind.server.ApplicationServerTransaction.callSynchronizationAfterCompletion(ApplicationServerTransaction.jav a:1074) at com.evermind.server.ApplicationServerTransactionManager.freeResources(ApplicationServerTransactionManager.java:355) at com.evermind.server.ApplicationServerTransaction.doCommit(ApplicationServerTransaction.java:249) at com.evermind.server.ApplicationServerTransaction.commit(ApplicationServerTransaction.java:126) at com.evermind.server.ApplicationServerTransactionManager.commit(ApplicationServerTransactionManager.java:433) at com.evermind.server.ApplicationServer$2.commit(ApplicationServer.java:4540) at com.evermind.server.ejb.EJBTransactionManager.end(EJBTransactionManager.java:136) at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:63) at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52) at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:86) at IEJBEventDispatcherSBLocal_StatelessSessionBeanWrapper62.dispatchEvent(IEJBEventDispatcherSBLocal_StatelessSessionBe anWrapper62.java:37) at com.senior.web.shared.EJBEventDispatcher.dispatchEvent(EJBEventDispatcher.java:49) at com.senior.web.faces.bean.administration.StudentParentDirectorySetupFace.load(StudentParentDirectorySetupFace.java:4 5)
    via by Jifeng Liu,
  • I got an exception as the summary. I add some related debug information and stack trace at the end. I am using a JTA EntityManager associated with current container managed transaction in a J2EE server. This happends when the stateless session bean finishs its excution. When current transaction commits, the current Session is closed by CacheSynchronization class. Then AbstractEntityManagerImpl$1.afterCompletion() method is called. this method trys to get transaction in the closed session object and causes the exception. 14:09:48 DEBUG AbstractFlushingEventListener - executing flush 14:09:48 DEBUG AbstractFlushingEventListener - post flush 14:09:48 DEBUG CacheSynchronization - transaction after completion callback, status: 3 14:09:48 DEBUG SessionImpl - after transaction completion 14:09:48 DEBUG CacheSynchronization - automatically closing session 14:09:48 DEBUG SessionImpl - automatically closing session 14:10:10 DEBUG SessionImpl - closing session org.hibernate.SessionException: Session is closed! at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49) at org.hibernate.impl.SessionImpl.getTransaction(SessionImpl.java:1281) at org.hibernate.ejb.AbstractEntityManagerImpl$1.afterCompletion(AbstractEntityManagerImpl.java:496) at com.evermind.server.ApplicationServerTransaction.callSynchronizationAfterCompletion(ApplicationServerTransaction.jav a:1074) at com.evermind.server.ApplicationServerTransactionManager.freeResources(ApplicationServerTransactionManager.java:355) at com.evermind.server.ApplicationServerTransaction.doCommit(ApplicationServerTransaction.java:249) at com.evermind.server.ApplicationServerTransaction.commit(ApplicationServerTransaction.java:126) at com.evermind.server.ApplicationServerTransactionManager.commit(ApplicationServerTransactionManager.java:433) at com.evermind.server.ApplicationServer$2.commit(ApplicationServer.java:4540) at com.evermind.server.ejb.EJBTransactionManager.end(EJBTransactionManager.java:136) at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:63) at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52) at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:86) at IEJBEventDispatcherSBLocal_StatelessSessionBeanWrapper62.dispatchEvent(IEJBEventDispatcherSBLocal_StatelessSessionBe anWrapper62.java:37) at com.senior.web.shared.EJBEventDispatcher.dispatchEvent(EJBEventDispatcher.java:49) at com.senior.web.faces.bean.administration.StudentParentDirectorySetupFace.load(StudentParentDirectorySetupFace.java:4 5)
    via by Jifeng Liu,
  • Hibernate Session closed problem!
    via Stack Overflow by Saher Ahwal
    ,
    • javax.persistence.PersistenceException: org.hibernate.SessionException: Session is closed! at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630) at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:510) at com.sun.jts.jta.SynchronizationImpl.before_completion(SynchronizationImpl.java:99) at com.sun.jts.CosTransactions.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:158) at com.sun.jts.CosTransactions.TopCoordinator.beforeCompletion(TopCoordinator.java:2548) at com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:278) at com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:249) at com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:623) at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:309) at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:1030) at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:397) at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792) at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3585) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:205) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127) at $Proxy142.processingFailed(Unknown Source) at com.sonybmg.aoma.transactionmanager.impl.MetadataImporterImpl.executeAttempt(MetadataImporterImpl.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067) at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176) at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127) at $Proxy138.executeAttempt(Unknown Source) at com.sonybmg.aoma.session.ProcessXMLSessionBean.processXML(ProcessXMLSessionBean.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067) at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176) at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127) at $Proxy139.processXML(Unknown Source) at com.sonybmg.aoma.transactionmanager.q.ImportXMLMDB.onMessage(ImportXMLMDB.java:58) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067) at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176) at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986) at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111) at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74) at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179) at $Proxy145.onMessage(Unknown Source) at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:258) at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:76) at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555) Caused by: org.hibernate.SessionException: Session is closed! at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49) at org.hibernate.impl.SessionImpl.getTransaction(SessionImpl.java:1314) at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:489) ... 56 more
    No Bugmate found.