11 Replies Latest reply on May 26, 2015 5:59 AM by Koen Aers

    Hibernate HQL editor

    Franck Gasparotto Newbie

      Hello,

      Since i use Eclipse Luna with the corresponding Hibernate Tools plugin, the hql editor doesn't work anymore the exception bellow show up when executing a request :

      I use hibernate 3 whose jars are in the lib folder of my webapp.

      Regarding the exception, i tried to add c3p0 and mchange jars to the classpath of the hibernate configuration but with no success.

      What am i am missing ? is this a bug ? On Eclipse Klepler everything worked perfectely with the same configuration.

       

      java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/DataSources

        at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:176)

        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)

        at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:51)

        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:91)

        at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)

        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)

        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)

        at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)

        at org.jboss.tools.hibernate.proxy.ConfigurationProxy.buildSessionFactory(ConfigurationProxy.java:111)

        at org.hibernate.console.ConsoleConfiguration$5.execute(ConsoleConfiguration.java:285)

        at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)

        at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:108)

        at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:280)

        at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:82)

        at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:56)

        at org.eclipse.jface.action.Action.runWithEvent(Action.java:519)

        at org.hibernate.eclipse.console.actions.ExecuteQueryAction.runWithEvent(ExecuteQueryAction.java:60)

        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)

        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)

        at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:462)

        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)

        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)

        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)

        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)

        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)

        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)

        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)

        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)

        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)

        at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)

        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)

        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)

        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)

        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)

        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)

        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)

        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)

        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)

        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)

        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.equinox.launcher.Main.invokeFramework(Main.java:648)

        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)

        at org.eclipse.equinox.launcher.Main.run(Main.java:1465)

        • 1. Re: Hibernate HQL editor
          Koen Aers Master

          Hi Franck,

           

          I am sorry you are experiencing this. This must be due to the C3P0 library not being on the classpath of Eclipse plugin. I have created [JBIDE-19144] Verify presence of C3P0 libraries on classpath of Hibernate runtime plugins - JBoss Issue Tracker to follow up on this.

          What version of Hibernate are you using? Also, I would be immensely grateful if you could give us a minimal project setup that produces this stack trace for the purpose of creating a unit test that guards against this problem in the future.

           

          Cheers,

          Koen

          • 2. Re: Re: Hibernate HQL editor
            Franck Gasparotto Newbie

            Hello Koen,

            Thanks for your concern. I try to get a minimum running project with a minimum of jars but i am stuck in a kind of "jar hell" as we don't use maven in our project and i don't have so much time to solve it. All i can do is giving you the hibernate jars we use in the project. It is a quite old version by the way : 3.3.2.GA.

            I hope it will help you.

            Franck

            • 3. Re: Re: Hibernate HQL editor
              Koen Aers Master

              Thanks, i will take a look at it. It might have to do with not properly disabling connection pooling in the tools as well.

              • 4. Re: Hibernate HQL editor
                Koen Aers Master

                Hey Franck,

                 

                I am a bit in the dart ATM with this issue. I don't want to go and change things blindly as that might break more than it would solve. Would it be possible to send me the file with your hibernate configuration and hibernate properties, so i can try and set up a project locally that mimics this problem. I assume you are using Hibernate 3.5 or 3.6 but I cannot determine it exactly from the zip file you posted. It would be good if you could confirm that as well.

                 

                In the meantime, I will punt the issue to 4.2.3.CR1 as it will not get solved by the code freeze tomorrow.

                 

                Cheers,

                Koen

                • 5. Re: Hibernate HQL editor
                  Jiri Peterka Newbie

                  Franck, I've also tried that with your libs with JBDS 8.1.0.CR1/JBT 4.2.3.CR1 and it works ok for me. If you problem still occur please bring more details.

                  • 6. Re: Hibernate HQL editor
                    Franck Gasparotto Newbie

                    Hello,

                    I tried it again with eclipse Luna SR2.

                    Here is a link to download the eclipse project : hibernate.zip - Google Drive . I tried to get the minimal number of jars (as far as I can) but as we don't use maven it was a bit difficult for me.

                    The SQL statements are in the "sql" folder. It is written in a postgresql syntax.

                     

                    To reproduce the error in the HQL editor just type : SELECT c FROM Civilite c

                    • 7. Re: Hibernate HQL editor
                      Franck Gasparotto Newbie

                      Can anyone try to reproduce the issue thanks to the project available on download ?

                      • 8. Re: Re: Hibernate HQL editor
                        Franck Gasparotto Newbie

                        Hi Koen,

                        Could you please try to reproduce my issue thanks to this minimum project : https://drive.google.com/file/d/0B7esnk52MpBJeTd3eGFsdG9PUjg/view?usp=sharing

                        Cheers

                        Franck

                        • 9. Re: Re: Hibernate HQL editor
                          Koen Aers Master

                          Hi Franck,

                           

                          Sorry I seem to have lost track of this.

                           

                          I have successfully imported your project and created the database. I am however facing a few issues in order to try to properly reproduce your problem. The imported project does not seem to be a JPA project (even though it contains a persistence.xml file and it logically should be a JPA project) nor does your project contain a hibernate configuration file or a Hibernate console definition. So executing the specified HQL doesn't work as we need a Hibernate console definition for this.

                          Can you please provide an updated project with a proper JPA facet and/or a Hibernate console definition?

                           

                          I have also seen that the hibernate version that you are using is version 3.3.2. This is quite outdated. Would it be possible to try with a version that is equal or higher than 3.5.x and ideally 4.3.x?

                           

                          Cheers,

                          Koen

                          • 10. Re: Re: Hibernate HQL editor
                            Koen Aers Master

                            Hi Franck,

                             

                            A little update.

                             

                            After converting your project into a JPA project (I used JPA 2.0) and expanding the created Hibernate console configuration, I see an exception that is probably related to the one you are reporting:

                             

                            org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]

                              at org.hibernate.cache.internal.NoCachingRegionFactory.buildEntityRegion(NoCachingRegionFactory.java:68)

                              at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:340)

                              at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)

                              at org.jboss.tools.hibernate.runtime.v_4_0.internal.ConfigurationFacadeImpl.buildTargetSessionFactory(ConfigurationFacadeImpl.java:24)

                              at org.jboss.tools.hibernate.runtime.common.AbstractConfigurationFacade.buildSessionFactory(AbstractConfigurationFacade.java:160)

                              at org.hibernate.console.ConsoleConfiguration$5.execute(ConsoleConfiguration.java:285)

                             

                            I am continuing my investigation based on this.

                             

                            Cheers,

                            Koen

                            • 11. Re: Hibernate HQL editor
                              Koen Aers Master

                              Hi Franck,

                               

                              I have finally an answer for your problem. The reason why your code stopped working is because of a major refactoring we performed when going from Kepler to Luna. This refactoring was needed to provide 'real' support for the different Hibernate versions. Before the refactoring most of the code used the org.hibernate.eclipse.libs plugin which contained Hibernate 3.5. In this libs plugin the jar file hibernate-ehcache was also included, effectively providing support for second level cache using EHCache. But it doesn't make a lot of sense to use caching in the tools (none of the tools code uses this) so when refactoring, we only kept the Hibernate jar files that were effectively needed by the tools. Because of this removal, your code stopped working.

                               

                              Now while this explains the problem, I can already hear you ask what the solution is. You can solve the problem in two ways.

                              - The first way would be to add the 'hibernate-ehcache.jar' file to the class path of your project.

                              - The second way, which is a bit cleaner because you don't need to deploy 'hibernate-ehcache.jar' along with your project, would be to create a 'hibernate.properties' file in your project and override the 'hibernate.cache.provider_class' property with an empty value ('hibernate.cache.provider_class='). Then for the Hibernate configuration linked to your project, you use this 'hibernate.properties' file in the launch configuration definition.

                               

                              I will create a blog post about this problem with a few screenshots. Let me know if this solves your problem.

                               

                              Cheers,

                              Koen