ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <>
Subject Re: Problem with xml-apis.jar located both in the classpath of a taskdef and ant lib.
Date Mon, 08 Jan 2007 14:34:55 GMT
carmel cohen wrote:
> 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.jaris 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:
> *<path id="fileHandler.classpath">
>  <pathelement location="./bin/fileHandler.jar"/>
>  <pathelement location="./bin/xalan.jar"/>
>  <pathelement location="./bin/xercesImpl.jar"/>
>  <pathelement location="./bin/xml-apis.jar"/>
> </path>
> <taskdef name="fileHandlerTask"
>   classname="com.impl**.ant.antTasks.PropertyFileHandlerTask"
>   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 .

XML parser handling is wierd; even having the new xalan/xerces on the 
tasks classpath isnt going to make it the default XML parser. Its not 
just a matter of the wrong api being picked up; ant -diagnostics will 
show you which xml parser is being created.
You will need to upgrade ant's libraries. Ant1.7.1 will ship with xerces 
2.7.0, incidentally.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message