[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

tomcat: HelloWorld and NoClassDefFoundError



Hello list,

I have a problem with Tomcat on Debian GNU/Linux stable (4.0).
I've already sent an email to the tomcat-users mailinglist, but
since I'm using a Debian packaged version of tomcat, and since
the people on the tomcat list suspect that it is Debian specific,
i'm asking my question here.  It is not the right place to ask,
please refer me to the correct place.

The problem is described in the mail below.  I should add that I
do have the simlink

  /usr/share/tomcat5.5/common/lib/servlet-api.jar

which symlinks to /usr/share/java/servlet-api.jar

I also noticed that the problem sometimes 'magically goes
away'... i wait for 10 to 20 minutes, then restart tomcat,
refresh the url for the servlet, and it works.  This makes me
believe that the servlet-api.jar file/link is correct, but that
it takes a while for tomcat to 'find' it.  However, i have no
clue what could be causing this.

Any help on this problem is highly appreciated.

Kind regards,
Bart


On Mon, Feb 09, 2009 at 03:34:41PM +0100, Bart Vandewoestyne wrote:
> 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


Reply to: