tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bart Vandewoestyne <Bart.Vandewoest...@telenet.be>
Subject HelloWorld and NoClassDefFoundError
Date Mon, 09 Feb 2009 14:34:41 GMT
Hello list,

I'm doing my first experiments with Tomcat and servlets.  Here's
my setup:

* Tomcat 5.5 runs on a Debian GNU/Linux 4.0 stable box and is
  installed via the packaging system (apt-get).

* The following tomcat and sun-java related packages are installed:

root@clydeT:~# dpkg --list | grep tomcat
ii  libtomcat5.5-java                5.5.20-2etch3                        Java Servlet engine
-- core libraries
ii  tomcat5.5                        5.5.20-2etch3                        Java Servlet 2.4
engine with JSP 2.0 support
ii  tomcat5.5-admin                  5.5.20-2etch3                        Java Servlet engine
-- admin & manager web i
ii  tomcat5.5-webapps                5.5.20-2etch3                        Java Servlet engine
-- documentation and exa
root@clydeT:~# dpkg --list | grep sun-java
ii  sun-java5-bin                    1.5.0-14-1etch1                      Sun Java(TM) Runtime
Environment (JRE) 5.0 (
ii  sun-java5-demo                   1.5.0-14-1etch1                      Sun Java(TM) Development
Kit (JDK) 5.0 demos
ii  sun-java5-jdk                    1.5.0-14-1etch1                      Sun Java(TM) Development
Kit (JDK) 5.0
ii  sun-java5-jre                    1.5.0-14-1etch1                      Sun Java(TM) Runtime
Environment (JRE) 5.0 (
ii  sun-java5-source                 1.5.0-14-1etch1                      Sun Java(TM) Development
Kit (JDK) 5.0 sourc

* Apparently, with this install, i have the following .jar files available under /usr/share/java:

  root@clydeT:/usr/share/java# ls *servlet*
  servlet-2.3.jar  servlet-api-2.4.jar  servlet-api.jar

  These files contain for example the HttpServlet class:

  root@clydeT:/usr/share/java# jar tf servlet-api.jar | grep HttpServlet\.class
  javax/servlet/http/HttpServlet.class

* I have a webapp running under http://host:8180/testbart/

* My webapp currently has the following files:

root@clydeT:/webapps/testbart# find
.
./WEB-INF
./WEB-INF/classes
./WEB-INF/classes/HelloServlet.class
./WEB-INF/lib
./WEB-INF/web.xml
./index.html

The class file was compiled using javac 1.5.0_16.
Notice also that there is no file in the lib directory.

When i trie to access the servlet using the URL

  http://clydet:8180/testbart/helloworld

I get

  java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet

I can solve this problem by copying /usr/share/java/servlet-api.jar to the
./WEB-INF/lib directory and restarting my tomcat... but somehow this seems
not the clean solution to me.  I expected tomcat to have servlet-api.jar
available in its classpath somehow, so that I don't need to copy this file for
every webapp I have.

My 2 questions are:

1) Is it necessary to copy servlet-api.jar to the WEB-INF/lib directory of
every web application that i have?  Or can i somehow tell tomcat that this
file is located in /usr/share/java?

2) Is there a way to find out which classpath tomcat is using?  And how does
the classpath for tomcat gets setup?

Thanks,
Bart

-- 
	"Share what you know.  Learn what you don't."

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message