jGuru Forums

Problem with xml-apis.jar located both in the classpath of a taskdef and ant lib.
0 posts in topic
Flat View
TOPIC ACTIONS:

Posted By:   Carmel_Cohen
Posted On:   Wednesday, January 10, 2007 12:27 PM

Hi, I am trying to write an ant task that uses xml-apis.jar. My problem is that i want to be able to define what version of xml-apis.jar is used. The jar is located both under %ANT_HOME%/lib (and the eclipse's ant lib if the ant is run from eclipse) and both in my project dir, under a library called "bin". so some classes (e.g. org.w3c.dom.Document, also found in the JRE lib- rt.jar) may appear in more then one location. The problem is that when i define a task as follows: &tab; classname="com.impl.ant.antTasks.PropertyFileHandlerTask" classpathref="fileHandler.c   More>>

Hi,

I am trying to write an ant task that uses xml-apis.jar.
My problem is that i want to be able to define what version of xml-apis.jar is used.
The jar is located both under %ANT_HOME%/lib (and the eclipse's ant lib if the ant is run from eclipse) and both in my project dir, under a library called "bin".
so some classes (e.g. org.w3c.dom.Document, also found in the JRE lib- rt.jar) may appear in more then one location.
The problem is that when i define a task as follows:

```

&tab;

classpathref="fileHandler.classpath"/>

```

Then during run time (I am trying to run it both from eclipse and command line) I am getting NoSuchMethodException due to the fact that the method getInputEncoding defined in Document was only added at xerces v 2.7, and the Document defined in the JRE lib and under %ANT_HOME%/lib/xml-apis.jar do not define this method.

My question is whether I can define the order of the jars in the classpath so that I will be able to make sure that the Classes that are defined in the fileHandler.classpath path will precede the classes defined in the other locations.

Updating the jar at %ANT_HOME%/lib/ is not an option because I want to be able to run this script from more then one location, so I want to find a solution that does not require any modifications in the machine that I am using .