You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Alberto Silva <al...@nmp.es> on 2000/09/15 09:21:14 UTC

ANT and classpath problem (newbie)

Hi,

I'm having an error when trying to compile with ant the sample web aplication that comes with tomcat-3.1 ($TOMCAT_HOME/docs/appdev/sample). I always get an eror about  'java.lang.NoClassDefFoundError'. I think the error is made by ant, but... I am newbie with Java, servlets and jsp, so i am not sure.

I get 3 diferent errors (I think the build.xml file is correct):


Error N1
=====================================================================
With this build shell script ...

------

# Identify the custom class path components we need
CP=$TOMCAT_HOME/classes:$TOMCAT_HOME/lib/ant.jar:$TOMCAT_HOME/lib/xml.jar
CP=$CP:$TOMCAT_HOME/lib/jasper.jar:$TOMCAT_HOME/lib/servlet.jar
CP=$CP:$TOMCAT_HOME/lib/webserver.jar

# Execute ANT to perform the requested build target
java -classpath $CP:$CLASSPATH org.apache.tools.ant.Main \
 -Dtomcat.home=$TOMCAT_HOME "$@"

------

... and this classpath ...

.:/usr/local/home/rbin/jdk1.2.2/lib:/usr/local/home/rbin/jdk1.2.2/lib/tools.jar
:/usr/local/home/rbin/jswdk-1.0.1/lib/servlet.jar:/usr/local/home/rbin/jswdk-1.0.1/lib/jsp.jar
:/usr/local/home/rbin/jaxp1.0.1/jaxp.jar:/usr/local/home/rbin/jaxp1.0.1/parser.jar
:/usr/local/home/rbin/ant/lib/ant.jar:/usr/local/home/rbin/ant/lib/moo.jar
:/usr/local/home/rbin/ant/lib/xml.jar


... I get this error:

[root@reznor sample]# ./build 
Couldn't find or load essential class `java/lang/Object' java.lang.NoClassDefFoundError java/lang/Object





Error N2
=====================================================================
With this build shell script (without the local classpath defined in the script)...

------

# Execute ANT to perform the requested build target
java org.apache.tools.ant.Main \
 - Dtomcat.home = $TOMCAT_HOME "$@"

------

... and this classpath ...

.:/usr/local/home/rbin/jdk1.2.2/lib:/usr/local/home/rbin/jdk1.2.2/lib/tools.jar
:/usr/local/home/rbin/jswdk-1.0.1/lib/servlet.jar:/usr/local/home/rbin/jswdk-1.0.1/lib/jsp.jar
:/usr/local/home/rbin/jaxp1.0.1/jaxp.jar:/usr/local/home/rbin/jaxp1.0.1/parser.jar
:/usr/local/home/rbin/ant/lib/ant.jar:/usr/local/home/rbin/ant/lib/moo.jar
:/usr/local/home/rbin/ant/lib/xml.jar

... I get this error:


[root@reznor sample]# ./build 
java.lang.ArrayIndexOutOfBoundsException
	at org.apache.tools.ant.Main.main(Main.java:142)





Error N3
=====================================================================
With this build shell script (without the local classpath defined in the script AND especifying a target to the build script)...

------

(the same script as case 2)

# Execute ANT to perform the requested build target
java org.apache.tools.ant.Main \
 - Dtomcat.home = $TOMCAT_HOME "$@"

------

... and this classpath ...

(the same classpath as case 2)

.:/usr/local/home/rbin/jdk1.2.2/lib:/usr/local/home/rbin/jdk1.2.2/lib/tools.jar
:/usr/local/home/rbin/jswdk-1.0.1/lib/servlet.jar:/usr/local/home/rbin/jswdk-1.0.1/lib/jsp.jar
:/usr/local/home/rbin/jaxp1.0.1/jaxp.jar:/usr/local/home/rbin/jaxp1.0.1/parser.jar
:/usr/local/home/rbin/ant/lib/ant.jar:/usr/local/home/rbin/ant/lib/moo.jar
:/usr/local/home/rbin/ant/lib/xml.jar

... I get this error:


[root@reznor sample]# ./build compile|all
Buildfile: build.xml
Detected Java Version: 1.2
Project base dir set to: /usr/local/home/root/devel/servlets/tomcat/sample/.
Executing Target: prepare
[copydir]Source directory /usr/local/home/root/devel/servlets/tomcat/sample/./lib does not exist.
Executing Target: compile
Compiling 1 source files to /home/rbin/tomcat-3.1/webapps/sample/WEB-INF/classesjava.lang.NoClassDefFoundError: java/util/ArrayList
	at org.apache.tools.ant.taskdefs.Javac.doClassicCompile(Javac.java:402)
	at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:221)
	at org.apache.tools.ant.Target.execute(Target.java:123)
	at org.apache.tools.ant.Project.runTarget(Project.java:471)
	at org.apache.tools.ant.Project.executeTarget(Project.java:370)
	at org.apache.tools.ant.Main.runBuild(Main.java:232)
	at org.apache.tools.ant.Main.main(Main.java:173)







Any idea?? The error changes and I have tried all the distributios from ant (ant1.1, ant1.0.8, ant from tomcat 3.1, ant from tomcat 3.0, src, nigthly, etc)


It seems that something is wrong with my jdk installation, I can't compile the ant or the tomcat src too, I always get the 'java.lang.NoClassDefFoundError'

My enviroment:
RedHat 6.1
JDK 1.2.2 Release Candidate 4
jswdk-1.0.1
jaxp1.0.1
Tomcat 3.1 (bin distro)
ant 1.1 (bin distro)


I would like to start making my own web applications, but without ant, it is imposible to me.

Lots of thanks for your support.







____________________________________________________________
Alberto Silva                 - alberto@nmp.es -       -o)
http://www.nmp.es             - 948 19 79 83   -        /\
GNU/Linux Registered and Supporter User N.122522       _\_v
____________________________________________________________
Ordenagailu baten gauzarik garrantzitsuena aulkia eta
teklatuaren artean dago