You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Robert Larsen <ro...@the-playground.dk> on 2011/07/08 14:02:59 UTC

taskdef A class needed by class X cannot be found: Task

Hi list

I am having a problem with an Ant installation on my Ubuntu 11.04.

I have a task which I have made myself and it has always worked (and
actually still does) but now I am getting the below error:

$ java -version && javac -version && ant -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
javac 1.6.0_24
Apache Ant version 1.8.1 compiled on October 13 2010
$ ant -f spritemap.xml
Buildfile: /home/robert/code/test/spritemap.xml

BUILD FAILED
/home/robert/code/test/spritemap.xml:3: taskdef A class needed by
class dk.cego.spritemapper.SpriteMapperTask cannot be found: Task
 using the classloader AntClassLoader[]

Total time: 0 seconds
$


On another machine however I get different results:
$ java -version && javac -version && ant -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
javac 1.6.0_24
Apache Ant version 1.8.1 compiled on October 13 2010
$ ant -f spritemap.xml
Buildfile: /home/robert/SpriteMapper/spritemap.xml

spritemap_trim:
[spritemap] Layouter used:
Guillotine(BestShortSideChooser,ShortestAxisSplitStrategy)
[spritemap] Resulting file is 1200 by 1462 pixels. Area is 1754400
square pixels.
[spritemap] Waste: 1%
[spritemap] Combined filesize: 1940786 Map filesize: 2277040

BUILD SUCCESSFUL
Total time: 2 seconds
$


I have googled this and can see that others have similar problems
(with other tasks thou) but not a working solution. Some have
suggested that having several versions of Ants classes loaded can
bring problems but on both machines the correct version is loaded (I
verified this with strace).
And the MD5 sum of all classes in /usr/share/ant/lib is the same all
the same files are loaded on both systems (in different order thou).
On the machine that fails:
$ strace -f ant -f spritemap.xml 2>&1|grep open|grep '.jar'|sed
's/.*"\(.*\)".*/\1/g'|xargs md5sum
6bdab51d6194c67d87cf04798bf8f364
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/rt.jar
37af554c699ef3c111cacc425b76b6fc  /usr/share/java/ant-launcher-1.8.1.jar
ba2c37a77600506cad2f0cd43b644ccd
/usr/share/maven-repo/javax/xml/jaxp-api/1.3/jaxp-api-1.3.jar
4ff5d1693f53efd8dd896a1a4455f7d7  /usr/share/java/xercesImpl-2.9.1.jar
82cb294674ba80a873e5dbe8a1ab239e  /home/robert/.ant/lib/SpriteMapper.jar
b31960add562a83ab98f7aec05424fd5  /usr/share/ant/lib/ant.jar
59e172f974c15d7720fbc345de0794aa  /usr/share/ant/lib/ant-javamail.jar
83e75d199a69105f1b4a45da65edf96f  /usr/share/ant/lib/ant-apache-oro.jar
b866a005fcd2359c022b8b30e46962b2  /usr/share/ant/lib/ant-apache-bsf.jar
37af554c699ef3c111cacc425b76b6fc  /usr/share/ant/lib/ant-launcher.jar
a424187753013263098f871b988ffa66  /usr/share/ant/lib/ant-apache-bcel.jar
a602bc912519abf1f880254a9d112e14  /usr/share/ant/lib/ant-jsch.jar
6aca7709b093bc66eddc35db11d30c41  /usr/share/ant/lib/ant-junit.jar
e5fa415ffece5e45d9eaa97d6b2cb305  /usr/share/ant/lib/ant-antlr.jar
73f01c5fea143194e71dca49a674a8de  /usr/share/ant/lib/ant-nodeps.jar
04a884ec7baa2808f6ca21272b386f59  /usr/share/ant/lib/ant-commons-net.jar
ce1fe292df3ca1c6cf0abef4010044e4  /usr/share/ant/lib/ant-apache-log4j.jar
30d9de0cee3200b492eeba7e9513e70d  /usr/share/ant/lib/ant-swing.jar
9d6b2d5bd33c11e83ef5255593b8b39d  /usr/share/ant/lib/ant-apache-regexp.jar
387e6c508bd112f5a014deec1102576d  /usr/share/ant/lib/ant-jdepend.jar
42d220c4c460e71def44d43da3aa2293  /usr/share/ant/lib/ant-jmf.jar
098c0a8dfdf7d3bb54b72927effc0ba6
/usr/share/ant/lib/ant-commons-logging.jar
e164ab5811a3a8911484d69fccf10e41  /usr/share/ant/lib/ant-apache-xalan2.jar
756a9b04d6874dfeccca05c49605de66
/usr/share/ant/lib/ant-apache-resolver.jar
3a144abb259517f50d2a78b43b4960bf
/usr/lib/jvm/java-6-sun-1.6.0.24/lib/tools.jar
b31960add562a83ab98f7aec05424fd5  /usr/share/ant/lib/ant.jar


On the machine that works:
$ strace -f ant -f spritemap.xml 2>&1|grep open|grep '.jar'|sed
's/.*"\(.*\)".*/\1/g'|xargs md5sum
6bdab51d6194c67d87cf04798bf8f364
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/rt.jar
37af554c699ef3c111cacc425b76b6fc  /usr/share/java/ant-launcher-1.8.1.jar
ba2c37a77600506cad2f0cd43b644ccd
/usr/share/maven-repo/javax/xml/jaxp-api/1.3/jaxp-api-1.3.jar
4ff5d1693f53efd8dd896a1a4455f7d7  /usr/share/java/xercesImpl-2.9.1.jar
82cb294674ba80a873e5dbe8a1ab239e  /home/robert/.ant/lib/SpriteMapper.jar
59e172f974c15d7720fbc345de0794aa  /usr/share/ant/lib/ant-javamail.jar
9d6b2d5bd33c11e83ef5255593b8b39d  /usr/share/ant/lib/ant-apache-regexp.jar
e5fa415ffece5e45d9eaa97d6b2cb305  /usr/share/ant/lib/ant-antlr.jar
42d220c4c460e71def44d43da3aa2293  /usr/share/ant/lib/ant-jmf.jar
37af554c699ef3c111cacc425b76b6fc  /usr/share/ant/lib/ant-launcher.jar
098c0a8dfdf7d3bb54b72927effc0ba6
/usr/share/ant/lib/ant-commons-logging.jar
83e75d199a69105f1b4a45da65edf96f  /usr/share/ant/lib/ant-apache-oro.jar
04a884ec7baa2808f6ca21272b386f59  /usr/share/ant/lib/ant-commons-net.jar
b31960add562a83ab98f7aec05424fd5  /usr/share/ant/lib/ant.jar
6aca7709b093bc66eddc35db11d30c41  /usr/share/ant/lib/ant-junit.jar
e164ab5811a3a8911484d69fccf10e41  /usr/share/ant/lib/ant-apache-xalan2.jar
b866a005fcd2359c022b8b30e46962b2  /usr/share/ant/lib/ant-apache-bsf.jar
a602bc912519abf1f880254a9d112e14  /usr/share/ant/lib/ant-jsch.jar
73f01c5fea143194e71dca49a674a8de  /usr/share/ant/lib/ant-nodeps.jar
a424187753013263098f871b988ffa66  /usr/share/ant/lib/ant-apache-bcel.jar
756a9b04d6874dfeccca05c49605de66
/usr/share/ant/lib/ant-apache-resolver.jar
387e6c508bd112f5a014deec1102576d  /usr/share/ant/lib/ant-jdepend.jar
30d9de0cee3200b492eeba7e9513e70d  /usr/share/ant/lib/ant-swing.jar
ce1fe292df3ca1c6cf0abef4010044e4  /usr/share/ant/lib/ant-apache-log4j.jar
3a144abb259517f50d2a78b43b4960bf
/usr/lib/jvm/java-6-sun-1.6.0.24/lib/tools.jar
b31960add562a83ab98f7aec05424fd5  /usr/share/ant/lib/ant.jar

Any ideas what I should do next ?
I feel like I have tried everything.


Have an awesome weekend
Robert


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


Re: taskdef A class needed by class X cannot be found: Task

Posted by Saturno <dr...@gmail.com>.
I'm facing a similar problem, and, after some researches I 've found this
explanation:

http://ant.apache.org/faq.html#delegating-classloader

I will try it now.

Best regards.

--
View this message in context: http://ant.1045680.n5.nabble.com/taskdef-A-class-needed-by-class-X-cannot-be-found-Task-tp4564505p4803641.html
Sent from the Ant - Users mailing list archive at Nabble.com.

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


Re: taskdef A class needed by class X cannot be found: Task

Posted by Robert Larsen <ro...@the-playground.dk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Dominique, thanks for the reply.

On 2011-07-08 15:40, Dominique Devienne wrote:
> I'm no expert, but have you tried -noclasspath and/or -nouserlib
> described here: http://ant.apache.org/manual/running.html ?
Just did but without any luck.
The -nouserlib won't work since my own task is in a jar in
$HOME/.ant/lib but I also tried moving all jars except this one out of
the library dir. Still without any luck.
>
> Depending how you got Ant installed, manually by downloading and
> expanding it yourself, or by using an OS-specific package manager,
> there had been reports in the past of problems with the way the
> various "packaged" Ants behaved compared to the "official" Ant. If
> you've used a packaged Ant, try using the official one instead,
> combined with -noclasspath at least.
I tried with a newly downloaded Ant and JDK:
$ ant -version && java -version && javac -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
javac 1.6.0_26

...but that didn't work either :-(

So, it is not Java, not Ant, not my own jar file (since it works on
another machine). Something in my setup must be at fault, but my
CLASSPATH environment variable is unset, $HOME/.java is deleted, and I
have verified with 'strace' that all the same jar files are loaded on
both the machine that works and the machine that doesn't.

Any other suggestions ?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk4aumYACgkQzDMeisFqGZZGWQCfdypow7j23x+TnXFT74P6+Zpp
Sd0An25fZJRI5ut3M2EPsrp7OhJhuYOl
=xTqX
-----END PGP SIGNATURE-----


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


Re: taskdef A class needed by class X cannot be found: Task

Posted by Dominique Devienne <dd...@gmail.com>.
On Fri, Jul 8, 2011 at 7:02 AM, Robert Larsen <ro...@the-playground.dk> wrote:
> I am having a problem with an Ant installation on my Ubuntu 11.04.
>
> I have a task which I have made myself and it has always worked (and
> actually still does) but now I am getting the below error: [...]
> Any ideas what I should do next ?
> I feel like I have tried everything.

I'm no expert, but have you tried -noclasspath and/or -nouserlib
described here: http://ant.apache.org/manual/running.html ?

Depending how you got Ant installed, manually by downloading and
expanding it yourself, or by using an OS-specific package manager,
there had been reports in the past of problems with the way the
various "packaged" Ants behaved compared to the "official" Ant. If
you've used a packaged Ant, try using the official one instead,
combined with -noclasspath at least.

Good luck. --DD

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