Error hibernate.properties not found

Trying to generate entity source code I get the above error with 5.4.4 Final
The following is my from my pom.xml file

   <executions>
             <execution>
                 <id>Display Help</id>
                 <phase>validate</phase>
                 <goals>
                     <goal>help</goal>
                 </goals>
             </execution>
             <execution>
                 <id>Entity generation</id>
                 <phase>generate-sources</phase>
                 <goals>
                     <goal>hbm2java</goal>
                 </goals>
             </execution>
         </executions>
         <configuration>
           <!--revengFile>src/main/hibernate/hibernate.reveng.xml</revengFile-->
           <!-- Defaults: -->
            <packageName></packageName>
            <configFile>${project.basedir}/src/main/hibernate/hibernate.cfg.xml</configFile>
            <detectManyToMany>true</detectManyToMany>
            <detectOneToOne>true</detectOneToOne>
            <detectOptimisticLock>true</detectOptimisticLock>
            <createCollectionForForeignKey>true</createCollectionForForeignKey>
            <createManyToOneForForeignKey>true</createManyToOneForForeignKey>
        </configuration>

hi dave,

can you please provide the error stack trace and a bit more context? is it something that used to work and all of a sudden stopped working? does it work with other versions?

cheers,
koen

Hi, I am using the maven hibernate tools plugin and this is not something that used to work. Here is a more complete stack trace

Failed to execute goal org.hibernate:hibernate-tools-maven-plugin:5.4.6.Final:hbm2java (default-cli) on project my-app: Execution default-cli of goal org.hibernate:hibernate-tools-maven-plugin:5.4.6.Final:hbm2java failed: /Users/davec/projects/testhbmtools/my-app/src/main/hibernate/hibernate.properties not found.: /Users/davec/projects/testhbmtools/my-app/src/main/hibernate/hibernate.properties (No such file or directory) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.hibernate:hibernate-tools-maven-plugin:5.4.6.Final:hbm2java (default-cli) on project my-app: Execution default-cli of goal org.hibernate:hibernate-tools-maven-plugin:5.4.6.Final:hbm2java failed: /Users/davec/projects/testhbmtools/my-app/src/main/hibernate/hibernate.properties not found.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.hibernate:hibernate-tools-maven-plugin:5.4.6.Final:hbm2java failed: /Users/davec/projects/testhbmtools/my-app/src/main/hibernate/hibernate.properties not found.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

Hi Dave,

I have done some investigation and there is indeed a bug when no “hibernate.properties” file is specified.

I have created HBX-1893 to track this.

You should be able to work around the issue by configuring a property file and creating a file (albeit empty) in the specified location.

<configuration>
  <propertyFile>${project.basedir}/src/main/java/hibernate.properties</propertyFile>
</configuration>

Let me know if this works.

Cheers,
Koen

Well this works but then it doesn’t seem to use the hibernate.cfg.xml file properly.
Here is my hibernate.cfg.xml file

?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE hibernate-configuration PUBLIC
         "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/music</property>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL10Dialect</property>
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>
        <property name="hbm2ddl.auto">update </property>
        <mapping class="com.mycompany.model.AlbumsEntity"/>
        <mapping class="com.mycompany.model.ArtistsEntity"/>
        <mapping class="com.mycompany.model.LyricsEntity"/>
        <mapping class="com.mycompany.model.SongsEntity"/>
        <mapping class="com.mycompany.model.WordsEntity"/>
    </session-factory>
</hibernate-configuration>

after providing an empty properties file I get an error that it can’t find a dialect
after providing a dialect in the properties file I get an error that it can’t find a connection.

Something must have gone wrong while pasting the hibernate.cfg.xml file I think. Could you provide it again?

I’ll do some more investigation. There seems to be more wrong than initially thought :slight_smile:

EDIT: Hmm never mind, now I can see it apparently…

I just edited the previous one.

OK, that explains it :smiley:

Hey Dave,

It turns out that the Maven plugin does not use the hibernate.cfg.xml file in any way at this moment. The only resource you have at this point is duplicating the relevant properties (driver class, url and dialect) in a hibernate.properties file which you point to as suggested above.
It would indeed be good to have a way of reading these properties from the hibernate.cfg.xml file. I’ll create a new issue for this.

I hope you can continue with these suggestions?

Cheers,
Koen