7 Replies Latest reply on Nov 18, 2007 12:02 PM by shivdeepk

    Error using Eclipse Hibernate Tools for JPA after greating p

    shivdeepk

      Hi All,

      I created a project using seam-gen. Opened the project in Eclipse. Opened Hibernate perspective. Opened "Hibernate Configurations". I now see the configuration for the created project. When I try to open the configuration I get a "HibernateConsoleRuntimeException: Could not load JPA configuration" error.

      I am trying to use the SchemaExport/Update functionality in Hibernate Tools. Is this a bug or is there anything else I need to do to make use of the Hibernate Tools GUI for JPA after creating a project using seam-gen.

      Any help would be appreciated.

      Kind Regards,
      Shivdeep

        • 1. Re: Error using Eclipse Hibernate Tools for JPA after greati
          maxandersen

          what error shows up in the error log view ?

          which version of seam and hibernate tools are you using ?

          • 2. Re: Error using Eclipse Hibernate Tools for JPA after greati
            shivdeepk

            This is my environment:

            Environment:

            Seam 2.0.0.GA
            JBoss Tools 2.0.0.beta4
            JBoss 4.2.1.GA
            Eclipse Platform Version: 3.3.0 Build id: M20070921-1145
            Linux (Ubuntu Gutsy)
            Postgresql 8.2


            Exception:

            org.hibernate.console.HibernateConsoleRuntimeException: Could not load JPA Configuration
            at org.hibernate.console.ConsoleConfiguration.buildConfiguration(ConsoleConfiguration.java:499)
            at org.hibernate.console.ConsoleConfiguration.access$0(ConsoleConfiguration.java:484)
            at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:203)
            at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
            at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:185)
            at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:106)
            at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:38)
            at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:89)
            at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:95)
            at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:196)
            at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
            Caused by: org.hibernate.console.HibernateConsoleRuntimeException: Could not create JPA based Configuration
            at org.hibernate.console.ConsoleConfiguration.buildJPAConfiguration(ConsoleConfiguration.java:142)
            at org.hibernate.console.ConsoleConfiguration.buildConfiguration(ConsoleConfiguration.java:496)
            ... 10 more
            Caused by: org.hibernate.console.HibernateConsoleRuntimeException: Persistence unit not found: 'null'.
            at org.hibernate.console.ConsoleConfiguration.buildJPAConfiguration(ConsoleConfiguration.java:134)
            ... 11 more


            hibernate-console.properties:

            #File used by hibernate tools to override <datasource> and other container specific settings in persistence.xml
            hibernate.connection.password=test123
            hibernate.connection.username=testuser
            hibernate.connection.driver_class=org.postgresql.Driver
            hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
            hibernate.connection.url=jdbc:postgresql:testdb
            hibernate.hbm2ddl.auto=update
            hibernate.connection.provider_class=org.hibernate.connection.DriverManagerConnectionProvider
            hibernate.datasource=
            hibernate.transaction.manager_lookup_class=


            testapp.launch:

            <?xml version="1.0" encoding="UTF-8" standalone="no"?>
            <launchConfiguration type="org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType">
            <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="testapp"/>
            <stringAttribute key="org.hibernate.eclipse.launch.CONFIGURATION_FACTORY" value="JPA"/>
            <listAttribute key="org.hibernate.eclipse.launch.FILE_MAPPINGS"/>
            <stringAttribute key="org.hibernate.eclipse.launch.PROPERTY_FILE" value="/testapp/hibernate-console.properties"/>
            </launchConfiguration>


            I observed there is no persistence.xml and orm.xml in resources->META-INF. There are 3 other persistence-*.xml. However the build.xml creates one when building & deploying the application. I could get a normal "JPA Project" working in eclipse.

            • 3. Re: Error using Eclipse Hibernate Tools for JPA after greati
              shivdeepk

              Is this a bug? I am following the "top-down" approach with hibernate. I have my domain model and would like to forward-engineer the database schema. My understanding is that Hibernate Tools can take over right after the project is created using seam-gen.

              • 4. Re: Error using Eclipse Hibernate Tools for JPA after greati
                shivdeepk

                I got this working eventually. I followed the "JPA Project" way and created a persistence.xml in src/META-INF. If I place persistence.xml in resources/META-INF along with the other persistence-*.xml files, it wouldnt work by default. I am disappointed in not being able to work with Hibernate Tools without any such hacks.

                • 5. Re: Error using Eclipse Hibernate Tools for JPA after greati
                  maxandersen

                  you mean having a structure in a JPA compliant structure is a hack ? :)

                  we can implement that we parse a custom named persistence.xml and pass it as a PersistenceUnit to the entitymanager but we haven't done it yet ....care for supplying a patch ? :)

                  • 6. Re: Error using Eclipse Hibernate Tools for JPA after greati
                    damianharvey

                    With a new Seam Gen project you have to run the 'buildtest' ant task that will create a persistence.xml in the 'test-build' directory. Hibernate tools will work from that.

                    Maybe this should be added to the Seam docs?

                    Cheers,

                    Damian.

                    • 7. Re: Error using Eclipse Hibernate Tools for JPA after greati
                      shivdeepk

                      following the JPA structure is not a hack...but doing it to get it working with hibernate tools, after seam-gen finishes its work is :-).

                      if seam-gen can create persistence-xxx.xml files, its no big deal for it to create a persistence.xml with the project name as the PersistenceUnit name by default.

                      going about r&d work to solve these issues negates the productivity gain acheived using seam. tools are the core of today's development scenario and such basic issues casts serious doubts.

                      Regards,
                      Shivdeep