How can I set the classpath of one third-party JAR to include a second third-party JAR in Ant?
I need this to run the vanilla Using Schematron with ANT example from this site. (I’m 99% sure you don’t need to know what Schematron is to answer this question.) The example’s instructions are in a short PDF linked near the top of the page. I copy-pasted the contents of all the files directly from the PDF into Eclipse.
I then downloaded ant-schematron-2010-04-14.jar from the above site, and got saxon9he.jar from the SAXON SourceForge page. I also changed the buildfile to match. With line numbers and without comments, it looks like this:
09 <project name="schematron-ant-sample" default="validate">
14 <taskdef name="schematron"
15 classname="com.schematron.ant.SchematronTask"
16 classpath="lib/ant-schematron-2010-04-14.jar; lib/saxon9he.jar" />
22 <target name="validate" description="Test with a Fileset">
23 <schematron schema="sch/sample.sch" failonerror="false">
24 <fileset dir="xml" includes="*.xml" />
25 </schematron>
26 </target>
27 </project>
When I ran the buildfile, I got the following error:
validate:
BUILD FAILED
C:\Users\gdawes\Documents\workspace\SchematronAntExample\build.xml:23: /
javax.xml.transform.TransformerFactoryConfigurationError: Provider /
net.sf.saxon.TransformerFactoryImpl not found
Total time: 265 milliseconds
A similar error occurs if the SAXON JAR isn’t listed in schematron‘s classpath. I’ve confirmed that TransformerFactoryImpl is present in the SAXON JAR, but I can’t figure out how to get the Schematron code to recognize it. How should I set up the classpath? (Or, if I’m wrong and this isn’t a classpath issue, how do I get the build to succeed?)
The
classpathin the<taskdef>should only contain:lib/ant-schematron-2010-04-14.jar, similar to the example provided in Using Schematron for Ant by example.In addition to correcting the
<taskdef>, placing thesaxon9he.jarin the Ant library folder makesnet.sf.saxon.TransformerFactoryImplavailable and resolves the error (tested on Ubuntu Linux with Ant 1.8.2).