1 2 Previous Next 23 Replies Latest reply on May 11, 2006 3:36 PM by maxandersen

    Hibernate Tools 1.5beta4 - Session is closed!

      I just download Hibernate Tools 1.5beta4 a moment ago. Everything looks good until I change my perspective to Hibernate Console and I try to open Hibernate Query Result tab. It has an error says "Session is closed!" and when I look in the detail it says:

      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.setActivePart(AbstractSelectionService.java:278)
       at org.eclipse.ui.internal.WorkbenchPagePartList.fireActivePartChanged(WorkbenchPagePartList.java:59)
       at org.eclipse.ui.internal.PartList.setActivePart(PartList.java:117)
       at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:2910)
       at org.eclipse.ui.internal.WorkbenchPage.requestActivation(WorkbenchPage.java:2512)
       at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:249)
       at org.eclipse.ui.internal.PartPane.setFocus(PartPane.java:295)
       at org.eclipse.ui.internal.PartStack.presentationSelectionChanged(PartStack.java:788)
       at org.eclipse.ui.internal.PartStack.access$0(PartStack.java:771)
       at org.eclipse.ui.internal.PartStack$1.selectPart(PartStack.java:119)
       at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:126)
       at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:267)
       at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:276)
       at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.access$1(DefaultTabFolder.java:1)
       at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder$2.handleEvent(DefaultTabFolder.java:84)
       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.Widget.sendEvent(Widget.java:867)
       at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
       at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:660)
       at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3138)
       at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1922)
       at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:288)
       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)
      


      I already check my database connection and it has no problem instead I can still see my database table in the view and I can run the reverse engineer code generation properly.

      I'm now using the latest Eclipse 3.1.2 and Java 1.4.2_7 Runtime.

      How can I fix this? Do I have to set something more? I already register my hibernate.cfg.xml to the console.

      Thank you and sorry for bad english anyway.

        • 1. Re: Hibernate Tools 1.5beta4 - Session is closed!
          maxandersen

          hmm...put the stacktrace in jira with a copy of your hibernate.cfg.xml

          and simply close the property view to avoid this happening.

          and yes, it is a bug...i just need to find out if it is in tools or the core.

          • 2. Re: Hibernate Tools 1.5beta4 - Session is closed!
            shahena

            Hi,
            Iam also having the same problem..Did you find solution for this..Pls help..
            Thnx

            • 3. Re: Hibernate Tools 1.5beta4 - Session is closed!
              maxandersen

              closing the property does not work for you ?

              the issue is that the operation session.contains() suddenly requires a ongoing transaction....i'll need to check if that is really necessary.

              • 4. Re: Hibernate Tools 1.5beta4 - Session is closed!
                lcoetzee

                Hi,

                has there been any development regarding this. I am rebuilding/downloading the nightly builds quite often but always get stuck with this.

                Regards.

                L

                • 5. Re: Hibernate Tools 1.5beta4 - Session is closed!
                  maxandersen

                  i have not been able to reproduce it so hard to fix.

                  • 6. Re: Hibernate Tools 1.5beta4 - Session is closed!
                    lcoetzee

                    Hi Max,

                    I have rebuilt the jboss-ide bundle from cvs (this morning Sunday 5 March) using the releng mechanims.

                    Installing the bundle and starting eclipse with -clean I used the wizard to create a new hibernate.cfg.xml, followed by a new hibernate console. All works as expected. The problem occurs when opening the hibernate console view, where I get the following exception when I try and create the session factory:

                    Problems while creating sessionfactory
                    
                    java.lang.NoSuchFieldError: extendsQueue
                    at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings(AnnotationConfiguration.java:143)
                    at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:276)
                    at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:213)
                    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
                    at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:265)
                    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35)
                    at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:68)
                    at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:260)
                    at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:24)
                    at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:69)
                    at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:192)
                    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)
                    


                    I have tried several other things (including just using the Hibernate Tools 1.5 beta 4), copying various versions of hibernate, hibernate-entity and other jars I could lay my hands on into the plugin, tried preventing hibernate from closing the session. No success.

                    My hibernate.cfg.xml is as follows:
                    <?xml version="1.0" encoding="UTF-8"?>
                    <!DOCTYPE hibernate-configuration PUBLIC
                     "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                     "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
                    <hibernate-configuration>
                     <session-factory name="sessionFactoryName">
                     <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
                     <property name="hibernate.connection.password">password</property>
                     <property name="hibernate.connection.url">jdbc:postgresql:nap</property>
                     <property name="hibernate.connection.username">napdba</property>
                     <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
                     </session-factory>
                    </hibernate-configuration>
                    


                    My console configuration:

                    <?xml version="1.0" encoding="UTF-8"?>
                    <hibernate-console>
                    <configuration annotations="true" name="hibernate-console-2">
                    <hibernate-config-xml location="/NAP/hibernate2.cfg.xml"/>
                    <classpath><path location="/NAP/lib/postgresql-jdbc3-8.1.jar"/><path location="/NAP/tmp/classes"/></classpath>
                    </configuration>
                    </hibernate-console>
                    


                    Hmm.. what other info can I provide so that we can trace this ? I am able to view the database elements when expanding Database in the console view. Unfortunately I can't execute HQL (or rather view the results), can't see the entity diagrams or any of those other very useful stuff !
                    I am running on a Linux platform with JDK 1.5_05. Against jboss 4.0.4 (built from cvs) with a Seam application.

                    Hope the info helps a bit.

                    Regards

                    Louis

                    • 7. Re: Hibernate Tools 1.5beta4 - Session is closed!
                      maxandersen

                      weird - this error is because the hibernate annotations jar is out of date.

                      i have updated and committed that a long time ago but for some reason anonymous cvs doesn't seem to get it...

                      workaround: take the latest release of hibernate annotations and put it in org.hibernate.eclipse/lib//hibernate-annotations.jar

                      • 8. Re: Hibernate Tools 1.5beta4 - Session is closed!
                        lcoetzee

                        I have been strugling to recompile the HibernateExt stuff to get hold of the latest hibernate-annotations.jar.

                        compile:
                         [javac] Compiling 51 source files to /home/lcoetzee/ftp/JBoss/Seam/HibernateEntityManager/HibernateExt/metadata/build/classes
                         [javac] /home/lcoetzee/ftp/JBoss/Seam/HibernateEntityManager/HibernateExt/metadata/src/java/org/hibernate/reflection/java/Comprehension.java:20: incompatible types
                         [javac] found : java.lang.Object
                         [javac] required: T
                         [javac] return collection.getClass().newInstance();
                         [javac] ^
                         [javac] 1 error
                        

                        Have't seen any updates coming through there for a few days (did see that it is being moved to subversion, but not accessible to me yet).

                        Anyway, the latest hibernate-annotations.jar I could find is the one distributed with jboss (I compile that from CVS as well). With this one I can actually open the session. Can't do any queries yet:

                        WARN main org.hibernate.hql.QuerySplitter -
                        no persistent classes found for query class: from csir.content.par.Content
                        


                        if I try a query such as :
                        from csir.content.par.Content
                        


                        In the hibernate console config I have added the jar to my jdbc driver as well as the classpath to where my compiled entities are stored. Still llearning about the configuration, but at least there is some progress. Any suggestion regarding the path to my ejb3 entities ?

                        Thanks

                        L

                        • 9. Re: Hibernate Tools 1.5beta4 - Session is closed!
                          maxandersen

                          no need to try and compile hibernate annotations -just use the latest release from hibernate.org (which the tools code is aligned with).

                          For the query issue is there no error shown ? e.g. a stacktrace ? Does Content have other dependencies that is not yet included into the console classpath ?

                          • 10. Re: Hibernate Tools 1.5beta4 - Session is closed!
                            lcoetzee

                            (Still using the hibernate-annotations stuff as distributed with jboss)

                            Can't think of other dependencies... except other entities which should be on the classpath as well..

                            When creating the session factory I get two warnings:



                            WARN main org.hibernate.impl.SessionFactoryObjectFactory - Could not bind factory to JNDI
                            
                            
                            javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
                             at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
                             at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
                             at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
                             at javax.naming.InitialContext.getNameParser(InitialContext.java:439)
                             at org.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
                             at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
                             at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:290)
                             at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
                             at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:265)
                             at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35)
                             at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:68)
                             at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:260)
                             at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:38)
                             at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:46)
                             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$5.handleEvent(ActionContributionItem.java:400)
                             at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
                             at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1021)
                             at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2867)
                             at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2572)
                             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(NativeMethodAccessorImpl.java:39)
                             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                             at java.lang.reflect.Method.invoke(Method.java:585)
                             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)
                            


                            as well as one about the ehcache:

                            WARN main org.hibernate.impl.SessionFactoryObjectFactory - Could not bind factory to JNDI


                            L


                            • 11. Re: Hibernate Tools 1.5beta4 - Session is closed!
                              maxandersen

                              hmm - weird that you can build the sessionfactory but not do queries ?

                              does:

                              "from java.lang.Object" work for you ?

                              does it return something and/or does the hql dynamic query translator view show some sql ?

                              • 12. Re: Hibernate Tools 1.5beta4 - Session is closed!
                                lcoetzee

                                When I try "from java.lang.Object" I get

                                WARN main org.hibernate.hql.QuerySplitter - no persistent classes found for query class: from java.lang.Object


                                Haven't seen any queries (sql), not able to view the entity model. Also interesting is that I am not able to expand the "Configuration" or "Session Factory" tags... I am able to expand the "Database" tag and view the tables in Hibernate Configuration pane.

                                Me actually quite confused at this point ;-)

                                L

                                • 13. Re: Hibernate Tools 1.5beta4 - Session is closed!
                                  maxandersen

                                  and you are completly sure that the console configuration is pointing to a hibernate.cfg.xml that list the entities/mapping files ?

                                  • 14. Re: Hibernate Tools 1.5beta4 - Session is closed!
                                    lcoetzee

                                    aaaahh... I think we are on to something here...

                                    my hibernate.cfg.xml was generated by the wizard, but does not contains any references to the entities (and I have no mappings because of ejb3)....

                                    L

                                    1 2 Previous Next