A class needed by class <...> cannot be found: org/apache/tools/ant/Task
(I spent quite a few hours fighting this one, so hopefully Google will help others find this page…) After toying
around with maven a bit, I discovered that none of my ant tasks would run. I hadn’t made any changes to anything in
$ANT_HOME, but all of sudden things broke. What I had done without thinking about it was to place
/Library/Java/Extensions. This jar contains the classes to create a few Ant task definitions. So here’s the rule…
Never place jars that are necessary for Ant task definitions in your Java classpath (
The problem is that Java tries to load these jars before it has loaded the Ant jars that they rely on. These jars that
contain task definitions should either be placed in the Ant classpath (
~/.ant/lib) or in your
project’s lib directory and referenced directly using the
classpath attribute of the
Comments and responses
I got this issue when I tried to set up a web service app with jaxws 2.1 to work.
I was having another issue, followed a link online suggested that all the jars for jaxws 2.1 should be put in jre/lib/endorsed. One of the jar file which defines Apt ant task is jaxws-tools.jar.And this stopped my Ant task invoking from eclipse to work.
Followed your instruction, i removed the endorsed dir from jdk1.6 dir and things started working again.
>so hopefully Google will help others find this page…
Indeed, it did. You’re even on rank one for that search.
So: Thank you very much, saved me a huge WOMBAT!