This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 52835 - Bundled Ant does not include Xerces in classpath; can affect JDK 1.4 users
Summary: Bundled Ant does not include Xerces in classpath; can affect JDK 1.4 users
Alias: None
Product: usersguide
Classification: Unclassified
Component: Code (show other bugs)
Version: 4.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: Talley Mulligan
Depends on:
Reported: 2005-01-01 14:36 UTC by tomsve
Modified: 2011-06-09 09:51 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description tomsve 2005-01-01 14:37:00 UTC
Is the bundled Ant installation somehow patched ?
It does not behave the same as the Ant version of
the same version number downloaded from!

Here is a version printout of the 2 ants:
tommy(build): sh
Apache Ant version 1.6.2 compiled on July 16 2004
tommy(build): ant -version
Using: /usr/local/development/apache-ant-1.6.2/bin/ant
Apache Ant version 1.6.2 compiled on July 16 2004

Notice that they claim to be the same version,
compiled on the same date.


Gives me a ton of exceptions due to Ant making the
Crimson XML parser included in jdk 1.4 available
in the classpath instead of xerces even though I
have the xerces jars in a <classpath> of the
<taskdef> for my ant task.


using the Ant 1.6.2 downloaded from apache
everything works fine since the xerces parser is
made available in the classpath as it should,
overriding the default Crimson parser in jdk 1.4.

This means that NB4 Ant 1.6.2 != Apache Ant 1.6.2!!

If NetBeans provides a patched version please
indicate that it is so that you know you are using
different ants. 

The workaround was to change the ant used in the
NetBeans options to the Apache version of ant.
Then my ant script works correctly even when run
from NetBeans.
Comment 1 Jesse Glick 2005-01-01 18:03:37 UTC
Ant itself is the same, but NetBeans does not automatically add a
special XML parser to the classpath - nor is it really required
generally for command-line Ant if you are using JDK 1.4+. (Ant bundles
Xerces in case you are using an older JDK which has no built-in JAXP

Build scripts should as a rule avoid implicit dependencies on the JAXP
implementations of SAX/DOM/XSLT in use; if your script/task
specifically needs Xerces (or Xalan etc.) for some reason (e.g.
calling Xerces-specific APIs, or using Xerces-only parser features)
then it is best to make this explicit by using some kind of
<classpath> either in the <taskdef> or set in the task itself. (Sounds
like you *tried* to do this, but apparently it did not work for
whatever reason - maybe a typo, maybe a class loader issue.)

In some cases it is really necessary to have certain JARs in the
original "classpath" for Ant. I am not aware of cases where this is
truly required for JAXP implementations, but it definitely happens for
bundled "optional" tasks with external library dependencies (<ftp> and
so on). For these cases, you can include the JAR in your $CLASSPATH
when running Ant from the command-line, or use "Additional Classpath"
in Ant Settings inside the IDE.

There should be no need to download Ant separately unless you

- need the manual or Javadoc, which to save download size NB does not
bundle (there is a NB module for download bundling the manual in the
internal help browser, but no Javadoc at the moment)

- need Xerces (and perhaps the XML-Commons APIs) in your classpath,
and don't want to bother downloading it separately and adding it

- want to be *sure* you are using the same environment as other people
in a team (e.g. for important release builds)

J.J. - please check the online help and release notes to make sure
these points are mentioned somewhere, wherever it is mentioned that
the IDE bundles Ant 1.6.2.
Comment 2 tomsve 2005-01-02 13:19:04 UTC
From below:

> then it is best to make this explicit by using some kind of
> <classpath> either in the <taskdef> or set in the task itself. 

I do have an explicit <classpath> in my <taskdef>! With the Ant 1.6.2
downloaded from this expicit classpath actually works!

When running the Netbeans 4.0 version of Ant 1.6.2 this explicit
<classpath> does not work, and I end up with the Crimson parser in JDK
1.4 which does not support schema validation (which is why I need

One and the same ant script is run using Ant 1.6.2 and
Netbeans 4.0 Ant 1.6.2 with different results. It does not matter if I
run the ant script within Netbeans or outside of it in a shell. The
result are the same. The Ant 1.6.2 always works, and
the Netbeans 4.0 Ant 1.6.2 always fails. The actual ant script being
run is not changed in any way between these runs!

Since setting the <classpath> in a <taskdef> should always work, I
still insist that the Netbeans 4.0 Ant 1.6.2 has a <classpath> bug for
<taskdef>, which the Ant 1.6.2 does not have!

Im very sorry, but I have to reopen this since I can't consider this
resolved for as long as the Ant supplied with Netbeans does not work,
and the exact same version of Ant downloaded from does.
That makes this a Netbeans problem not an Ant problem.

I can also add that I downloaded the zip version of Ant 1.6.2. Maybee
you got the tar.gz version for inclusion in Netbeans ? Maybe they
differ slightly ?

When we downloaded Netbeans 4.0 in my current project some people got
the windows installer and some got the zip distribution. After
installing, those that intalled using the windows installer were
missing half the project templates that were all available in the zip
distribution. Maybee the Ant gang made a similar miss?

Anyhow the zip version of Ant 1.6.2 at does work, so
maybee you can just do a fresh download of that and replace the
current Ant 1.6.2 in Netbeans 4.0. 

Best Regards,
Tommy Svensson

Comment 3 Jesse Glick 2005-01-02 17:42:45 UTC
Several points here.

1. This is still an incomplete issue - reporter has not provided any
steps to reproduce the problem. If you can supply a *complete* test
case that demonstrates the problem than resolution (as a fix or as a
better explanation) would be feasible with some work, otherwise not.

2. As I said before, the Ant JARs included in NetBeans are identical
to those downloaded in Ant 1.6.2. You can see for yourself:

$ diff -r /space/ant162 /space/nb/curr/ide5/ant
Only in /space/ant162: docs
Only in /space/nb/curr/ide5/ant: extra
Only in /space/ant162: KEYS
Only in /space/ant162/lib: README
Only in /space/ant162/lib: xercesImpl.jar
Only in /space/ant162/lib: xml-apis.jar
Only in /space/ant162: LICENSE
Only in /space/ant162: LICENSE.dom
Only in /space/ant162: LICENSE.sax
Only in /space/ant162: LICENSE.xerces
Only in /space/nb/curr/ide5/ant: nblib
Only in /space/ant162: NOTICE
Only in /space/ant162: README
Only in /space/ant162: TODO
Only in /space/ant162: welcome.html
Only in /space/ant162: WHATSNEW

3. Again, the difference in your case is probably the presence of
xercesImpl.jar (and perhaps xml-apis.jar) in the lib dir of a
downloaded Ant distribution. NetBeans intentionally does not ship
these JARs since they are unnecessary for most purposes in JDK 1.4;
and JDK 1.5, which is preferred for running NB, includes Xerces
anyway. Try removing them and see if your script still works on the
command line (using the same JDK as you run NB with). I believe you
that the script with <classpath> works when run from command-line Ant
but that may simply mean that the <classpath> is not doing anything at
all and your script is relying on the parser shipped with Ant. Of
course without a demo script I can only guess.

4. If you see any discrepancy between NB installed via Windows
installer and NB unpacked from a ZIP file, trust the ZIP file and file
a (separate) bug report with steps to reproduce from scratch if you
have them - there should be no difference. Check which user directory
you are using in both cases.
Comment 4 tomsve 2005-01-02 22:11:04 UTC
In response to:

1. I should know better, having been on the other side a lot myself :-)
   I should have provided a runnable example. Sorry.
3. Aha! So there is a small difference! This actually explains 
   it! I got the xerces path wrong in my <classpath>. It still works
   with Ant since it still provides the xerces jars 
   and the miss goes unnoticed, but with NB 4.0 Ant no xerces will 
   be available causing a problem! I am running jdk 1.4 which includes
   the older Crimson parser, which is the one I actually got when 
   running NB 4.0 Ant, which threw a java.lang.IllegalArgumentException
   when my code told it to schema validate.

Mystery solved! I restore the INVALID status on this issue.

I however think ... eh ... never mind, I'll just be quiet.

/Tommy Svensson
Comment 5 Jesse Glick 2005-01-03 17:31:01 UTC
OK, so my guess was correct... still need some better mention of the
discrepancy in documentation somewhere, though, for our remaining JDK
1.4 users. JJ, any ideas where it can go?
Comment 6 John Jullion-ceccarelli 2005-01-19 18:50:10 UTC
I would suggest an FAQ, definitely, and we should put it into the
Working with Ant introduction page (as well as the Ant version number,
which seems to have gotten accidentally cut out of that page). Don't
know if that's visible enough but can't think of anywhere else to put it.
Comment 7 Talley Mulligan 2005-02-18 10:55:01 UTC
mention of this limitation was added to the Working with Ant online
help topic (ant_intro.html) - please comment if additional information
is necessary...
Comment 8 Marian Mirilovic 2011-06-09 09:51:23 UTC