You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bart Vandewoestyne <Ba...@telenet.be> on 2009/02/09 15:34:41 UTC

HelloWorld and NoClassDefFoundError

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


Re: HelloWorld and NoClassDefFoundError

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bart,

Caldarale, Charles R wrote:
>> From: Bart Vandewoestyne [mailto:Bart.Vandewoestyne@telenet.be]
>> Subject: HelloWorld and NoClassDefFoundError
> 
>> I get
>>   java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
> 
> Indicative of a broken Tomcat installation, which is pretty typical
> with these 3rd-party repackaged versions.  I strongly suggest you
> throw away that junk and install a real Tomcat from
> tomcat.apache.org;

In contrast to Chuck's comments, I would recommend that you take your
complaint to the appropriate Debian forum and figure out why the
package-managed version isn't working. I happen to agree with Chuck that
these things are almost always broken, but they'll never get fixed
unless Debian users continue to complain to the package managers.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmQ3TgACgkQ9CaO5/Lv0PDPFwCcDW+qd14irSIcp3oq+tHZnDl3
mngAnjgQXmMkdOE9MjDIiQ1//a2RPdAX
=2W3S
-----END PGP SIGNATURE-----

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


Re: HelloWorld and NoClassDefFoundError

Posted by André Warnier <aw...@ice-sa.com>.
Bart Vandewoestyne wrote:
[...]
> 
> Actually, yes, I would like to use the Debian package.  I like
> the ease of installing/upgrading/removing packages with apt-get.
> 
Hi.
Just to reassure you : I have a series of Linux Debian systems with 
Tomcat 4.1, 5.0 and 5.5, all installed via apt-get, and I don't think 
the installation is broken per se. They all work fine.
Just make sure the JVM is a Sun one, not the gcj, and that it is 
installed and made the default "alternative" *before* you install the 
Tomcat packages.

At another level however Chuck is right, in that it is very difficult 
for Tomcat experts to help when there is a problem with the packages 
distributed with the various Linux distributions, because each one has 
it's own file layout, with links all over the place to all over the 
place, so compared to a standard Tomcat from tomcat.apache.org it is 
difficult to figure out where the files should be.


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


RE: HelloWorld and NoClassDefFoundError

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Bart Vandewoestyne [mailto:Bart.Vandewoestyne@telenet.be]
> Subject: Re: HelloWorld and NoClassDefFoundError
>
> Actually, yes, I would like to use the Debian package.  I like
> the ease of installing/upgrading/removing packages with apt-get.

If you can't reproduce the problem on a real Tomcat installation, you'll need to take any Tomcat questions or comments you have to the Debian list.  Debugging broken 3rd-party installations is pointless.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

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


Re: HelloWorld and NoClassDefFoundError

Posted by Bart Vandewoestyne <Ba...@telenet.be>.
On Mon, Feb 09, 2009 at 08:49:06AM -0600, Caldarale, Charles R
wrote:
>
> Indicative of a broken Tomcat installation, which is pretty
> typical with these 3rd-party repackaged versions.  I strongly
> suggest you throw away that junk and install a real Tomcat from
> tomcat.apache.org; this mailing list is littered with problem
> reports from attempted use of non-standard Tomcat
> installations.  If you insist on using the package from Debian,
> you'll need to consult whatever Debian support mechanisms there
> are.

Actually, yes, I would like to use the Debian package.  I like
the ease of installing/upgrading/removing packages with apt-get.

While I was investigating the problem, I started to notice that
it 'magically went away' somehow... so I did the following test:

* Compile a class file and put it under WEB-INF/classes/
* restart tomcat
* check the URL -> i get the NoClassDefFound error (for HttpServlet)
  that i described earlier.

-> now I wait for about 10 to 20 minutes

* I restart tomcat
* I refresh the webpage in my browser... and now magically it
  works!


What I conclude from this, is that the servlet-api.jar is at the
right place, but somehow it takes a while for tomcat to notice
this.

My only problem is that, taking into account the above behavior, I
have no clue where to look for the possible cause of this.

If somebody could point me in the right direction, it would be
very much appreciated.

Kind regards,
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


RE: HelloWorld and NoClassDefFoundError

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Gregor [mailto:rc46fi@googlemail.com]
> Subject: Re: HelloWorld and NoClassDefFoundError
>
> the spelling is perfectly fine - duh! ;)

Unless you happen to live in Springfield, and your name is Homer.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

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


Re: HelloWorld and NoClassDefFoundError

Posted by Gregor <rc...@googlemail.com>.
the spelling is perfectly fine - duh! ;)

Am 09.02.2009 um 20:22 schrieb André Warnier <aw...@ice-sa.com>:

> Caldarale, Charles R wrote:
>>> From: André Warnier [mailto:aw@ice-sa.com]
>>> Subject: Re: HelloWorld and NoClassDefFoundError
>>>
>>> does one need to login ? and if yes, with what ?
>> Yes, you must login.  The button is on the top line of the page,  
>> towards the right.  After that, you can edit to your heart's content.
> Thanks.
> Or duh, as my Californian friends would say. Well, I know how they  
> say it, not necessarily how they write it.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

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


Re: HelloWorld and NoClassDefFoundError

Posted by André Warnier <aw...@ice-sa.com>.
Caldarale, Charles R wrote:
>> From: André Warnier [mailto:aw@ice-sa.com]
>> Subject: Re: HelloWorld and NoClassDefFoundError
>>
>> does one need to login ? and if yes, with what ?
> 
> Yes, you must login.  The button is on the top line of the page, towards the right.  After that, you can edit to your heart's content.
> 
Thanks.
Or duh, as my Californian friends would say. Well, I know how they say 
it, not necessarily how they write it.

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


RE: HelloWorld and NoClassDefFoundError

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: André Warnier [mailto:aw@ice-sa.com]
> Subject: Re: HelloWorld and NoClassDefFoundError
>
> does one need to login ? and if yes, with what ?

Yes, you must login.  The button is on the top line of the page, towards the right.  After that, you can edit to your heart's content.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

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


Re: HelloWorld and NoClassDefFoundError

Posted by André Warnier <aw...@ice-sa.com>.
Mark Thomas wrote:
> Gregor Schneider wrote:
>> Hm, this answer has been given quite a few times recently - I guess it
>> makes sens to put it on the FAQ: http://wiki.apache.org/tomcat/FAQ
> 
> That is a Wiki anyone can edit so go for it.
> 
I must be thick, but I've tried to find the way to edit/add to that 
thing, and I don't see it.  All the pages seem to display an "immutable 
page" indication, and I could not find a button or link to edit.
I am not familiar with wikis (hate to admit it, age shows).  Is there a 
trick ? does one need to login ? and if yes, with what ?

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


Re: HelloWorld and NoClassDefFoundError

Posted by Mark Thomas <ma...@apache.org>.
Gregor Schneider wrote:
> Hm, this answer has been given quite a few times recently - I guess it
> makes sens to put it on the FAQ: http://wiki.apache.org/tomcat/FAQ

That is a Wiki anyone can edit so go for it.

Mark

> 
> Rgds
> 
> Gregor
> 
> On Mon, Feb 9, 2009 at 3:49 PM, Caldarale, Charles R
> <Ch...@unisys.com> wrote:
>> Indicative of a broken Tomcat installation, which is pretty typical with these 3rd-party repackaged versions.  I strongly suggest you throw away that junk and install a real Tomcat from tomcat.apache.org; this mailing list is littered with problem reports from attempted use of non-standard Tomcat installations.  If you insist on using the package from Debian, you'll need to consult whatever Debian support mechanisms there are.
>>
>>> I expected tomcat to have servlet-api.jar
>>> available in its classpath somehow
>> A real Tomcat installation does not have this problem.
>>
>>> 1) Is it necessary to copy servlet-api.jar to the
>>> WEB-INF/lib directory of every web application that
>>> i have?
>> Not only is it not necessary, it is not allowed.
>>



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


Re: HelloWorld and NoClassDefFoundError

Posted by Gregor Schneider <rc...@googlemail.com>.
Hm, this answer has been given quite a few times recently - I guess it
makes sens to put it on the FAQ: http://wiki.apache.org/tomcat/FAQ

Rgds

Gregor

On Mon, Feb 9, 2009 at 3:49 PM, Caldarale, Charles R
<Ch...@unisys.com> wrote:
>
> Indicative of a broken Tomcat installation, which is pretty typical with these 3rd-party repackaged versions.  I strongly suggest you throw away that junk and install a real Tomcat from tomcat.apache.org; this mailing list is littered with problem reports from attempted use of non-standard Tomcat installations.  If you insist on using the package from Debian, you'll need to consult whatever Debian support mechanisms there are.
>
>> I expected tomcat to have servlet-api.jar
>> available in its classpath somehow
>
> A real Tomcat installation does not have this problem.
>
>> 1) Is it necessary to copy servlet-api.jar to the
>> WEB-INF/lib directory of every web application that
>> i have?
>
> Not only is it not necessary, it is not allowed.
>
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

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


RE: HelloWorld and NoClassDefFoundError

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Bart Vandewoestyne [mailto:Bart.Vandewoestyne@telenet.be]
> Subject: HelloWorld and NoClassDefFoundError

> I get
>   java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet

Indicative of a broken Tomcat installation, which is pretty typical with these 3rd-party repackaged versions.  I strongly suggest you throw away that junk and install a real Tomcat from tomcat.apache.org; this mailing list is littered with problem reports from attempted use of non-standard Tomcat installations.  If you insist on using the package from Debian, you'll need to consult whatever Debian support mechanisms there are.

> I expected tomcat to have servlet-api.jar
> available in its classpath somehow

A real Tomcat installation does not have this problem.

> 1) Is it necessary to copy servlet-api.jar to the
> WEB-INF/lib directory of every web application that
> i have?

Not only is it not necessary, it is not allowed.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

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


Re: HelloWorld and NoClassDefFoundError

Posted by Bart Vandewoestyne <Ba...@telenet.be>.
On Mon, Feb 09, 2009 at 03:34:41PM +0100, Bart Vandewoestyne wrote:
>
> [...]
> 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?

For the record: I forgot to mention that my Debian install
provides a symlink

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

that links to

/usr/share/java/servlet-api.jar

So i don't understand why tomcat or my webapp can't find it...

Regards,
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