Resolving Dependency Conflicts in Maven
Posted by Martin Homik | Posted in Java | Posted on 12-02-2008
0
Today, I ran into a problem which turned out to be a Maven dependency conflict. It all began with running a a set of JUnit tests on my AppFuse project with MySQL as backend. Even standard add/remove tests on the simplest class terminated with an InvalidDataAccessResourceUsageException caused by Hibernate. When I switched to PostgreSQL, all tests were successful.
At first, I thought that the error originated in MySQL or in my POM parameters, but I could not find anything on the net that confirmed my suspicion. Eventually, I came across a Hibernate Jira issue, which explains that particular behaviour. Hibernate did not specify any value for row id.
I searched AppFuse’s POM for a Hibernate dependency and found this: the POM itself does not state that it requires a specific Hibernate version. But it relies on AppFuse’s static repository and its dependencies which are implicitly present in my POM. However, I’ve been working with hyperjaxb3 recently which depends on an hibernate-entitymanager of version 3.3.1.ga which in turn includes a buggy Hibernate jar mentioned in the issue. As hyperjaxb3’s dependency versions are lower than those of AppFuse, Maven decided to use the lower version to get things running. Hence, the problem.
Now, to solve the problem you can either remove hyperjaxb3’s dependency or just change tge version to a version range.
-
<dependency>
-
<groupid>org.hibernate</groupid>
-
<artifactid>hibernate-entitymanager</artifactid>
-
<version>[3.3.1.ga,]</version>
-
<scope>test</scope>
-
</dependency>
The range means that Maven should use the latest available hibernate-entitymanager, but no older than that of version 3.3.1.ga.

