This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes maven surefire junit hibernate dependency issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "maven surefire junit hibernate dependency issue" Watch "maven surefire junit hibernate dependency issue" New topic

maven surefire junit hibernate dependency issue

Robert Hogan

Joined: Apr 09, 2007
Posts: 4
Hi I am converting a build procedure from ant to maven and have a set of junit test the exercise a mysql database via a hibernate layer.

The tests are set up to run via the surefire plugin.

When I run I get errors during my hibernate session factory setup (which runs out of a @Before method). I resolved the errors by adding antlr-runtime and javaassist artifacts to my dependency tree. This , however , puzzles me to no end as already have hibernate-core on my list of dependencies.

By my way of thinking I should not have had to add the secondary dependencies; in fact, our whole motivation for moving to maven is to eliminate these kinds of problems .

Anyone ???

Peter Johnson

Joined: May 14, 2008
Posts: 5812

No solution for you offhand, but here is what you can do to get to the root cause of this issue. I've done this quite often...

First, run the Maven build you currently have passing the -X option. This will generate a lot of output so you should redirect stdout and stderr to a file. Among the information available will be the classpath built for running the unit tests. And actually, you can see that same classpath by examining the manifest in the JAR file located in the target/surefire directory.

Now do the same thing with your prior pom.xml. What you are looking for is things that are different. That should bring something to mind which will lead to a solution.

JBoss In Action
I agree. Here's the link:
subject: maven surefire junit hibernate dependency issue
Similar Threads
Could not resolve dependencies
Could not resolve dependencies for maven project
[Maven] Accessing classpath information from JUnit tests executed by Surefire
Incorrect hibernate version or maven ignore and didn't download hibernate jar file.
In order to run junit 4.8.2 in maven do we need to have the folder src/test/java?