ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Use of XML Catalog with Ant (xslt task) - request for example
Date Sat, 14 Sep 2013 04:48:44 GMT
On 2013-09-13, Kerry, Richard wrote:

> "ant-resolver.jar and xml-resolver.jar "

> hang on a moment .............  what are these ?

> I thought I just needed resolver.jar from xml-commons-resolver-1.2
> (assuming that's the latest), so what are these two ?

xml-resolver.jar is the one from xml-commons, it comes under different
names, sorry for the confusion.

ant-resolver.jar is part of the Ant distribution and contains the
binding between Ant and the xml-commons resolver.

> And (previous response) I don't touch ant-apache-resolver.jar, which
> is already under ant/lib, as it's an internal library

Then resolver.jar from xml-commons must be there as well or things won't
work because of classloader delegation.

> What is not clear to me is which one of these files needs to be
> specified in the <xmlcatalog> element.  Given that the properties file
> specifies the (relative) location of the catalog file itself I assume
> that's the one I need to specify.  Can someone please confirm this, or
> explain otherwise ?

I don't think the properties file is required at all.  Yes, you directly
point to the catalog itself.

> I am seeing the following messages :

> "Apache resolver library not found, internal resolver will be used
> Failed to load Apache resolver: java.lang.NoClassDefFoundError: org/apache/xml/resolver/tools/CatalogResolver"

> Which looks like it's saying I haven't got the resolver loaded.

Right, see above.  The manual about xmlcatalog also has this innocent
note "but they will be ignored unless the resolver library from
xml-commons is available in the *system classpath*" (emphasis by me).
The resolver.jar from xml-commons must be either on CLASSPATH or inside
$ANT_HOME/lib or ~/.ant/lib or specified via -lib

Java builds a hierarchy of classloaders and the way Ant uses them
classes loaded high up in the hierarchy cannot see classes loaded
further down.  At the root there is CLASSPATH and nested <classpath>
elements are loaded via a loader further down the hierarchy.

Ant's binding to xml-resolver (the ant-resolver.jar) is loaded high up
in the hierarchy - at least higher than any <classpath> element - and so
the resolver.jar from xml-commons must be located at least as high
inside the hierarchy for Ant to find it.

In essence this is a case very similar to

<http://ant.apache.org/faq#delegating-classloader> if you ignore the
first sentence of the answer which is specific to <junit>.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message