views:

188

answers:

1

Hello,

in our web-app project, we include some jar files. For patching some issues of one of the classes in a jar file, we changed the implemention of this class in a patches source folder.

Since there is a defined class loading order in tomcat (WEB-INF/classes before WEB-INF/lib), the patched version of the class is loaded by tomcat, not the original one in the jar file. So, as soon as we deploy our application, everything works as expected.

Now, we want to run junit tests from ant against this patched class. So we configure the class path to hold both, the original jar and the patched class file. But there seems to be no way to tell the ant's junit task to first load the patched class, not the unpatched version from the jar file.

Is there a way to get around the problem? Is there a way to determine the order in which the classes are loaded by ant's junit task? Is there any other way to test our patched class from ant?

A: 

I think an ant classpath works just like the standard Java classpath. The classpath is searched in the order that paths are declared and a class is loaded from the first path where it is found.

Your classpath element for your junit task should be something like:

<classpath>
  <pathelement location="${patched.class.folder}"/>
  <pathelement location="${original.class.jar}"/>
</classpath>
Mark