Over the weekend the Jenkins build started failing. The error leads me to believe that someone didn’t verify their build before committing code, and that the configuration file now has a problem:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2ddl (create-schema) on project incident-service:
Execution create-schema of goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2ddl failed:
Could not parse configuration: file:/var/lib/jenkins/jobs/IncidentService/workspace/target/classes/hibernate.cfg.xml
Except, there were no changes to the code; nothing changed in this file, and it’s been working fine for about a month or two. The environment the build server is on changed however. It cannot get to certain parts of the internet:
jenkins@hudson1:~$ wget http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd --2011-10-10 10:48:06-- http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd Resolving www.hibernate.org... 209.132.182.21 Connecting to www.hibernate.org|209.132.182.21|:80... failed: Connection timed out. Retrying.
It’s not actually able to get to the internet to validate the DTD within that hibernate.cfg.xml file. This should not break our build. It was a source of much frustration for about 4 hours of the day. Various hibernate forums were of limited help.
Apparently it should get it from the jar, rather than the internet, if the jar is available on the class path and the DTD matches. First our DTD was incorrect. Rectified that, and yet it still tried to get it off the internet. WTF?
Turns out the hibernate3-maven-plugin doesn’t include any hibernate jars when it executes.
Solution is to duplicate the necessary hibernate dependencies for the plugin to have the necessary DTD data available:
<dependencies>
<!--
Need to include the following hibernate dependencies so that it can find the DTD
without having to get it off the internet.
-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.0.0.GA</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
</dependencies>
So some context: This is to support preventing the hibernate3-maven-plugin from going to the internet to get the DTD every time it parses that hibernate.cfg.xml file. There’s no data in this file, only a shell of a hibernate.cfg.xml; just enough of a placeholder to keep the hbm2ddl Goal from failing, as we’ll eventually have it build DDL for us.
Content:
<?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> <!-- specify annotated classes here, because the hbm2ddl plugin isn't capable of searching for them :( --> </session-factory> </hibernate-configuration>
Quite an irritating error for something that seems to actually do nothing. Apparently it does. Stupid XML

