----------------------------------------------------------------------
Message: 1
Date: Thu, 7 Apr 2005 15:06:28 -0400
From: David Parsons <email@hidden>
Subject: ant results in NoClassDefFoundError
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=us-ascii
Hi all:
This sounds like such a simple question: what is wrong with my apache-ant setup to result in a NoClassDefFoundError?
I have a project build-file which uses an ant directive which is unavailable in ant v1.5, so I wondered off to ant.apache.org and downloaded v1.6.2. I installed it into /usr/local/, reset the symlink (/usr/local/ant) to point to /usr/local/apache-ant-1.6.2 then tried running ant on my build-file. The resulting error was: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher.
After some searching, this error seems to be caused most often by having more than one version of ant around which is referenced by the CLASSPATH. I don't have a set CLASSPATH and going back to the old version (either by redoing the symlink or calling it with an absolute path) works just fine. NetBeans seems to have its own version of ant, but NetBeans works just fine building against my build.xml. The apple-dev list search hasn't been terribly fruitful. There are few references to upgrading ant, and one reference to someone having it worked out.
Of the things I've tried so far: I've simply tried resetting CLASSPATH to be empty (which it was before, so I didn't expect much); I've set the ANT_HOME to be first in my classpath; I've tried calling the ant script with the --noconfig option (see http://forum.java.sun.com/thread.jspa?threadID=549080&start=15&tstart=0).
What was originally at /usr/local/ant was a symlink to /Library/Java/Webservices/apache-ant -- Webservices is the location I gave for JWSDP installation. It's required for the project I'm on, so I cannot just remove it (though as an aside, if someone has some better ideas than having the users install the Java WebServices so my users are able to read XML files from standalone apps, please share!). I think that it still recognises and runs the Webservices' ant is peculiar. Furthermore, the terminal will not (nor will xterm) run a command-line ant -other- than the Webservices' version. I cannot make it run my recent download from apache.org, nor the ant included with NetBeans. Is there some Info.plist that is a holdover? Something else? I'm missing something and I think it is not ant-specific but peculiar to my installation. I've run out of ideas on where to further sort this one out.
About my setup (from a clean term!):
Welcome to Darwin!
orthos:~>uname -a; echo $PATH
Darwin orthos.cit.nih.gov 7.8.0 Darwin Kernel Version 7.8.0: Wed Dec 22 14:26:17 PST 2004; root:xnu/xnu-517.11.1.obj~1/RELEASE_PPC Power Macintosh powerpc
/usr/bin:/bin:/usr/sbin:/sbin:/Users/parsonsd:/Users/parsonsd/bin:/usr/local/ant/bin
orthos:~>echo $JAVA_HOME; which java; java -version
/Library/Java/Home
/usr/bin/java
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141.4)
Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)
orthos:~>echo $ANT_HOME; which ant; ant -version
/usr/local/ant
/usr/local/ant/bin/ant
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
orthos:~>ls -la $ANT_HOME
lrwxr-xr-x 1 root admin 27 7 Apr 11:48 /usr/local/ant -> /usr/local/apache-ant-1.6.2
orthos:~>/Library/Java/WebServices/apache-ant/bin/ant -version
Apache Ant version 1.5.4 compiled on October 10 2003
Any pointers here?
../dave.