org.hibernate.SessionException: Session is closed!

Hibernate JIRA | Markus Junginger | 1 decade ago
  1. 0

    "ERROR main org.hibernate.hql.PARSER - <AST>:0:0: unexpected end of subtree" shows up if no elements are available for "Session factory" (double click in the "Hibernate Configuration" Eclipse view). Also "Session is closed" error in the log. !MESSAGE Exception while executing HQL Query !SUBENTRY 1 org.hibernate.eclipse.console 4 150 2006-02-13 11:13:42.116 !MESSAGE org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [] !STACK 0 org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:225) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1601) at org.hibernate.console.HQLQueryPage.setSession(HQLQueryPage.java:77) at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:292) at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35) at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:287) at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:282) at org.hibernate.eclipse.console.views.KnownConfigurationsView$3.run(KnownConfigurationsView.java:133) at org.hibernate.eclipse.console.views.KnownConfigurationsView$1.doubleClick(KnownConfigurationsView.java:77) at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:720) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044) at org.eclipse.core.runtime.Platform.run(Platform.java:783) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148) at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:718) at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(StructuredViewer.java:950) at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1057) at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:219) at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:216) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:275) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3125) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2758) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) 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.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948) Caused by: <AST>:0:0: unexpected end of subtree at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2943) at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688) at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544) at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218) ... 46 more !ENTRY org.eclipse.ui.workbench 4 0 2006-02-13 11:13:13.522 !MESSAGE Session is closed! !STACK 0 org.hibernate.SessionException: Session is closed! at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:50) at org.hibernate.impl.SessionImpl.contains(SessionImpl.java:1574) at org.hibernate.eclipse.console.views.properties.HibernatePropertySourceProvider.getPropertySource(HibernatePropertySourceProvider.java:35) at org.eclipse.ui.views.properties.PropertySheetEntry.getPropertySource(PropertySheetEntry.java:456) at org.eclipse.ui.views.properties.PropertySheetEntry.setValues(PropertySheetEntry.java:728) at org.eclipse.ui.views.properties.PropertySheetEntry.refreshValues(PropertySheetEntry.java:597) at org.eclipse.ui.views.properties.PropertySheetEntry.createChildEntries(PropertySheetEntry.java:241) at org.eclipse.ui.views.properties.PropertySheetEntry.getChildEntries(PropertySheetEntry.java:339) at org.eclipse.ui.views.properties.PropertySheetViewer.updateCategories(PropertySheetViewer.java:981) at org.eclipse.ui.views.properties.PropertySheetViewer.updateChildrenOf(PropertySheetViewer.java:1146) at org.eclipse.ui.views.properties.PropertySheetViewer.setInput(PropertySheetViewer.java:877) at org.eclipse.ui.views.properties.PropertySheetPage.selectionChanged(PropertySheetPage.java:392) at org.eclipse.ui.views.properties.PropertySheet.selectionChanged(PropertySheet.java:212) at org.eclipse.ui.internal.AbstractSelectionService.fireSelection(AbstractSelectionService.java:156) at org.eclipse.ui.internal.AbstractSelectionService$1.selectionChanged(AbstractSelectionService.java:62) at org.hibernate.eclipse.console.views.QueryPageTabView.fireSelectionChangedEvent(QueryPageTabView.java:151) at org.hibernate.eclipse.console.views.QueryPageTabView.fireSelectionChangedEvent(QueryPageTabView.java:165) at org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(QueryPageTabView.java:108) at org.hibernate.eclipse.console.views.QueryPageTabView$1.contentsChanged(QueryPageTabView.java:52) at javax.swing.AbstractListModel.fireContentsChanged(Unknown Source) at org.hibernate.console.QueryPageModel.remove(QueryPageModel.java:92) at org.hibernate.eclipse.console.actions.CloseQueryPageAction.run(CloseQueryPageAction.java:45) at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3125) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2758) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) 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.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948)

    Hibernate JIRA | 1 decade ago | Markus Junginger
    org.hibernate.SessionException: Session is closed!
  2. 0

    "ERROR main org.hibernate.hql.PARSER - <AST>:0:0: unexpected end of subtree" shows up if no elements are available for "Session factory" (double click in the "Hibernate Configuration" Eclipse view). Also "Session is closed" error in the log. !MESSAGE Exception while executing HQL Query !SUBENTRY 1 org.hibernate.eclipse.console 4 150 2006-02-13 11:13:42.116 !MESSAGE org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [] !STACK 0 org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:225) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1601) at org.hibernate.console.HQLQueryPage.setSession(HQLQueryPage.java:77) at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:292) at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35) at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:287) at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:282) at org.hibernate.eclipse.console.views.KnownConfigurationsView$3.run(KnownConfigurationsView.java:133) at org.hibernate.eclipse.console.views.KnownConfigurationsView$1.doubleClick(KnownConfigurationsView.java:77) at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:720) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044) at org.eclipse.core.runtime.Platform.run(Platform.java:783) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148) at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:718) at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(StructuredViewer.java:950) at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1057) at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:219) at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:216) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:275) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3125) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2758) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) 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.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948) Caused by: <AST>:0:0: unexpected end of subtree at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2943) at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688) at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544) at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218) ... 46 more !ENTRY org.eclipse.ui.workbench 4 0 2006-02-13 11:13:13.522 !MESSAGE Session is closed! !STACK 0 org.hibernate.SessionException: Session is closed! at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:50) at org.hibernate.impl.SessionImpl.contains(SessionImpl.java:1574) at org.hibernate.eclipse.console.views.properties.HibernatePropertySourceProvider.getPropertySource(HibernatePropertySourceProvider.java:35) at org.eclipse.ui.views.properties.PropertySheetEntry.getPropertySource(PropertySheetEntry.java:456) at org.eclipse.ui.views.properties.PropertySheetEntry.setValues(PropertySheetEntry.java:728) at org.eclipse.ui.views.properties.PropertySheetEntry.refreshValues(PropertySheetEntry.java:597) at org.eclipse.ui.views.properties.PropertySheetEntry.createChildEntries(PropertySheetEntry.java:241) at org.eclipse.ui.views.properties.PropertySheetEntry.getChildEntries(PropertySheetEntry.java:339) at org.eclipse.ui.views.properties.PropertySheetViewer.updateCategories(PropertySheetViewer.java:981) at org.eclipse.ui.views.properties.PropertySheetViewer.updateChildrenOf(PropertySheetViewer.java:1146) at org.eclipse.ui.views.properties.PropertySheetViewer.setInput(PropertySheetViewer.java:877) at org.eclipse.ui.views.properties.PropertySheetPage.selectionChanged(PropertySheetPage.java:392) at org.eclipse.ui.views.properties.PropertySheet.selectionChanged(PropertySheet.java:212) at org.eclipse.ui.internal.AbstractSelectionService.fireSelection(AbstractSelectionService.java:156) at org.eclipse.ui.internal.AbstractSelectionService$1.selectionChanged(AbstractSelectionService.java:62) at org.hibernate.eclipse.console.views.QueryPageTabView.fireSelectionChangedEvent(QueryPageTabView.java:151) at org.hibernate.eclipse.console.views.QueryPageTabView.fireSelectionChangedEvent(QueryPageTabView.java:165) at org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(QueryPageTabView.java:108) at org.hibernate.eclipse.console.views.QueryPageTabView$1.contentsChanged(QueryPageTabView.java:52) at javax.swing.AbstractListModel.fireContentsChanged(Unknown Source) at org.hibernate.console.QueryPageModel.remove(QueryPageModel.java:92) at org.hibernate.eclipse.console.actions.CloseQueryPageAction.run(CloseQueryPageAction.java:45) at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3125) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2758) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) 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.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948)

    Hibernate JIRA | 1 decade ago | Markus Junginger
    org.hibernate.SessionException: Session is closed!
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    I am using the ThreadLocalContext transaction with hibernate. This application was wrote with hibernate 2.1.7 and work well, but decide migrate to hibernate 3.1.1. I Extended the class ThreadLocalContext to overwrite the next methods: protected ConnectionReleaseMode getConnectionReleaseMode() { return ConnectionReleaseMode.ON_CLOSE; } protected boolean isAutoCloseEnabled() { return false; } protected Session buildOrObtainSession() { Session s = (Session) threadSession.get(); try { if((s!=null && !s.isOpen() )) s = null; if(s!=null){ if(s.isDirty() || !s.isOpen() || !s.isConnected()){ s.close(); s = null; } } if (s == null) { log.debug("Session is null - take new Session"); s = this.factory.openSession(); threadSession.set(s); } bind(s); } catch (HibernateException ex) { log.error("Error take a new Session - " + ex.getMessage()); throw new DCMHibernateException(ex); } return s; } This i do because in the API javadoc, in class ThreadLocalContext say let you a handler more time session in scope. The application init, do some stuff with database throw hibernate but when arrive time to save the Object com.mjoy.dcmbase.entities.Sesion (Bussines Object) that contain an attribute must be serialize, throws the next stackTrace: 27-01-2006 13:34:20 DEBUG [SerializationHelper.serialize:141] Starting serialization of object [{opcionesUsuario={D=com.mjoy.dcmbase.entities.DescTono@1509443, A=com.mjoy.dcmbase.entities.DescTono@1eaf705, F=com.mjoy.dcmbase.entities.DescTono@51ddd2, H=com.mjoy.dcmbase.entities.DcmObject@192ee25, C=com.mjoy.dcmbase.entities.DescTono@16e2b70, B=com.mjoy.dcmbase.entities.DescTono@4aad7f, G=com.mjoy.dcmbase.entities.DescTono@1a5678, E=com.mjoy.dcmbase.entities.DescTono@1f07360}, paginado=[com.mjoy.dcmbase.entities.DescTono@afcd0c, com.mjoy.dcmbase.entities.DescTono@ed3007, com.mjoy.dcmbase.entities.DescTono@1b0caf], ranking=com.mjoy.dcmbase.entities.Ranking@39b99d}] org.hibernate.SessionException: Session is closed! at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:50) at org.hibernate.impl.SessionImpl.getPersistenceContext(SessionImpl.java:1794) at org.hibernate.proxy.BasicLazyInitializer.getReplacement(BasicLazyInitializer.java:100) at org.hibernate.proxy.BasicLazyInitializer.invoke(BasicLazyInitializer.java:54) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:156) at com.mjoy.dcmbase.entities.Medio$$EnhancerByCGLIB$$52ca026d.writeReplace(<generated>) 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:324) at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:896) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1011) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278) at java.util.HashMap.writeObject(HashMap.java:980) 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:324) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:809) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1296) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278) at org.hibernate.util.SerializationHelper.serialize(SerializationHelper.java:148) at org.hibernate.util.SerializationHelper.serialize(SerializationHelper.java:172) at org.hibernate.type.SerializableType.toBytes(SerializableType.java:74) at org.hibernate.type.SerializableType.deepCopyNotNull(SerializableType.java:70) at org.hibernate.type.MutableType.deepCopy(MutableType.java:25) at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:323) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:255) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:529) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:521) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:517) 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:324) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:292) at $Proxy0.saveOrUpdate(Unknown Source) at com.mjoy.dcmbase.persistence.PersistenceManager.saveOrUpdate(PersistenceManager.java:247) at com.mjoy.dcmbase.entities.Sesion.saveOrUpdate(Sesion.java:221) at com.mjoy.dcm.handler.RankingLogic.empiezaTransaccion(RankingLogic.java:104) at com.mjoy.dcm.handler.VentaRankingHandler.execute(VentaRankingHandler.java:76) at com.mjoy.dcm.servlets.DCM.doAction(DCM.java:115) at com.mjoy.dcm.servlets.DCM.doGet(DCM.java:149) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:534) 27-01-2006 13:34:22 DEBUG [PersistenceManager.saveOrUpdate:250] Error save or updating object - com.mjoy.dcmbase.entities.Sesion Session is closed! 27-01-2006 13:34:22 ERROR [Sesion.saveOrUpdate:223] Error saving sesion org.hibernate.SessionException: Session is closed! I post in the hibernate Forum but nobody can help me. below i write the code with mapping Sesion class and with the code when call the saveOrUpdate(obj) and throw excpetion describe above -Mapping class Sesion: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping > <class name="com.mjoy.dcmbase.entities.Sesion" table="sesion" > <id name="id" column="id" type="java.lang.Long" unsaved-value="null" > <generator class="native"> <!-- To add non XDoclet generator parameters, create a file named hibernate-generator-params-Sesion.xml containing the additional parameters and place it in your merge dir. --> </generator> </id> <property name="atributos" type="serializable" update="true" insert="true" column="datos" not-null="false" unique="false" /> <property name="linea" type="java.lang.Long" update="true" insert="true" column="linea" not-null="false" unique="false" /> <property name="status" type="java.lang.Integer" update="true" insert="true" column="status" not-null="false" unique="false" /> <property name="fecha" type="java.sql.Timestamp" update="true" insert="true" column="fecha" not-null="false" unique="false" /> <!-- To add non XDoclet property mappings, create a file named hibernate-properties-Sesion.xml containing the additional properties and place it in your merge dir. --> </class> <query name="ObtenerSesionLinea"><![CDATA[ from Sesion as s where s.linea like :linea ]]></query> </hibernate-mapping> -PersistenceManager Class: /** * * Este metodo tiene la siguiente funcionalidad: * * * @return */ private static SessionFactory instancia() { if (sessionFactory == null) { try { Configuration cfg = new Configuration(); log.debug("Iniciando configuraciĆ³n de hibernate"); cfg.configure(); sessionFactory = cfg.buildSessionFactory(); log.debug("Obtienendo SessionFactory "); } catch (HibernateException e) { log.error("Error initialize Session Factory hibernate :" + e.getMessage()); throw new DCMHibernateException(e.getMessage()); } catch (Exception e) { e.printStackTrace(); } } return sessionFactory; } /** * Cierra la cession; * */ public static Session getSession() { try { beginTransaction(); return instancia().getCurrentSession(); } catch (HibernateException ex) { log.error("Error closing session session - " + ex.getMessage()); throw new DCMHibernateException(ex); } } /** * Cierra la cession; * */ public static void closeSession() { try { Session s = getSession(); log.debug("Take session from thread"); if ((s != null)) { log.debug("Closing session"); s.close(); } } catch (HibernateException ex) { log.error("Error closing session session - " + ex.getMessage()); throw new DCMHibernateException(ex); } } /** * Inicia una transaccion * */ public static void beginTransaction() { try { Session s = instancia().getCurrentSession(); if(s.getTransaction()!=null && s.getTransaction().isActive()){ log.debug("Ya existe la transaccion y Esta Activa"); return; }else if(s.getTransaction()!=null){ log.debug("Ya existe transaccion pero no esta activa ........"); s.getTransaction().begin(); log.debug("Activando una nueva.........."); }else{ log.debug("Iniciando una nueva transaccion"); s.beginTransaction(); } } catch (HibernateException ex) { log.error("Error taking new transaction object - " + ex.getMessage()); throw new DCMHibernateException(ex); } } /** * Comitea las transacciones y cierra las sesiones * */ public static void commitTransaction() { Transaction tx = (Transaction) getSession().getTransaction(); log.debug("Trake transaction from thread"); try { if ((tx != null) && !tx.wasCommitted() && !tx.wasRolledBack()) { log.debug("Commiting transaction before closing"); tx.commit(); } } catch (HibernateException ex) { log.error("Error commiting transaction - " + ex.getMessage()); rollbackTransaction(); throw new DCMHibernateException(ex); } finally { log.debug("Close sesion transaction"); closeSession(); } } /** * Realiza un rollback si ocurre un error * */ public static void rollbackTransaction() { Transaction tx = (Transaction) getSession().getTransaction(); log.debug("Take transaction from thread"); try { if ((tx != null) && !tx.wasCommitted() && !tx.wasRolledBack()) { log.debug("Rollbak transaction"); tx.rollback(); } } catch (HibernateException ex) { log.error("Error rollback transaction - " + ex.getMessage()); throw new DCMHibernateException(ex); } finally { log.debug("Closing session"); closeSession(); } } /** * Actualiza o inserta un objeto en la base segun corresponda * @param obj */ public static void saveOrUpdate(Object obj) { try { log.debug("Save or Updating object - " + obj.getClass().getName()); Session s = getSession(); s.saveOrUpdate(obj); } catch (HibernateException e) { e.printStackTrace(); log.debug("Error save or updating object - " + obj.getClass().getName() + " \n " + e.getMessage()); throw new DCMHibernateException(e); } } Please i want to kwon if this is a bug or i had very poor ackwonlegde to version hibernate 3.1.1 handler session. I want to migrate to hibernate 3.1 but if this not work i return to 2.1.x version Thank you

    Hibernate JIRA | 1 decade ago | Juan Pablo Royo
    org.hibernate.SessionException: Session is closed!

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.SessionException

      Session is closed!

      at org.hibernate.impl.AbstractSessionImpl.errorIfClosed()
    2. Hibernate
      SessionImpl.contains
      1. org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:50)
      2. org.hibernate.impl.SessionImpl.contains(SessionImpl.java:1574)
      2 frames
    3. org.hibernate.eclipse
      HibernatePropertySourceProvider.getPropertySource
      1. org.hibernate.eclipse.console.views.properties.HibernatePropertySourceProvider.getPropertySource(HibernatePropertySourceProvider.java:35)
      1 frame
    4. Eclipse UI
      PropertySheet.selectionChanged
      1. org.eclipse.ui.views.properties.PropertySheetEntry.getPropertySource(PropertySheetEntry.java:456)
      2. org.eclipse.ui.views.properties.PropertySheetEntry.setValues(PropertySheetEntry.java:728)
      3. org.eclipse.ui.views.properties.PropertySheetEntry.refreshValues(PropertySheetEntry.java:597)
      4. org.eclipse.ui.views.properties.PropertySheetEntry.createChildEntries(PropertySheetEntry.java:241)
      5. org.eclipse.ui.views.properties.PropertySheetEntry.getChildEntries(PropertySheetEntry.java:339)
      6. org.eclipse.ui.views.properties.PropertySheetViewer.updateCategories(PropertySheetViewer.java:981)
      7. org.eclipse.ui.views.properties.PropertySheetViewer.updateChildrenOf(PropertySheetViewer.java:1146)
      8. org.eclipse.ui.views.properties.PropertySheetViewer.setInput(PropertySheetViewer.java:877)
      9. org.eclipse.ui.views.properties.PropertySheetPage.selectionChanged(PropertySheetPage.java:392)
      10. org.eclipse.ui.views.properties.PropertySheet.selectionChanged(PropertySheet.java:212)
      10 frames
    5. Eclipse UI
      AbstractSelectionService$1.selectionChanged
      1. org.eclipse.ui.internal.AbstractSelectionService.fireSelection(AbstractSelectionService.java:156)
      2. org.eclipse.ui.internal.AbstractSelectionService$1.selectionChanged(AbstractSelectionService.java:62)
      2 frames
    6. org.hibernate.eclipse
      QueryPageTabView$1.contentsChanged
      1. org.hibernate.eclipse.console.views.QueryPageTabView.fireSelectionChangedEvent(QueryPageTabView.java:151)
      2. org.hibernate.eclipse.console.views.QueryPageTabView.fireSelectionChangedEvent(QueryPageTabView.java:165)
      3. org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(QueryPageTabView.java:108)
      4. org.hibernate.eclipse.console.views.QueryPageTabView$1.contentsChanged(QueryPageTabView.java:52)
      4 frames
    7. Java RT
      AbstractListModel.fireContentsChanged
      1. javax.swing.AbstractListModel.fireContentsChanged(Unknown Source)
      1 frame
    8. org.hibernate.console
      QueryPageModel.remove
      1. org.hibernate.console.QueryPageModel.remove(QueryPageModel.java:92)
      1 frame
    9. org.hibernate.eclipse
      CloseQueryPageAction.run
      1. org.hibernate.eclipse.console.actions.CloseQueryPageAction.run(CloseQueryPageAction.java:45)
      1 frame
    10. Eclipse UI
      BaseSelectionListenerAction.runWithEvent
      1. org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)
      1 frame
    11. JFace
      ActionContributionItem$6.handleEvent
      1. org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538)
      2. org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
      3. org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441)
      3 frames
    12. RWT
      Display.readAndDispatch
      1. org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
      2. org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
      3. org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3125)
      4. org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2758)
      4 frames
    13. Eclipse UI
      Workbench.createAndRunWorkbench
      1. org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
      2. org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
      3. org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
      3 frames
    14. Eclipse UI
      IDEApplication.run
      1. org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
      2. org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
      2 frames
    15. Eclipse Core
      PlatformActivator$1.run
      1. org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
      1 frame
    16. Eclipse OSGi
      EclipseStarter.run
      1. org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
      2. org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
      2 frames
    17. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      4. java.lang.reflect.Method.invoke(Unknown Source)
      4 frames
    18. Equinox
      Main.main
      1. org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
      2. org.eclipse.core.launcher.Main.basicRun(Main.java:278)
      3. org.eclipse.core.launcher.Main.run(Main.java:973)
      4. org.eclipse.core.launcher.Main.main(Main.java:948)
      4 frames