tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Francis <chris.fran...@static2358.com>
Subject RE: jar's still not picked up in WEB-INF/lib
Date Mon, 09 Oct 2000 16:18:34 GMT

Hi, 
I'm new to this list but joined it to find out about specifically this
problem.
Today I had a strange one - TOMCAT_HOME/lib/webserver.jar was not found! The
only 
way I got it to pick up those classes was to extract the jar into the
classes 
directory. Although removing the entry in startup.bat and putting it on the
global classpath would probabaly work aswell.  
WEB-INF/lib rarely works and I generally add those jars to tomcats startup
classpath
and or the global. 
Anyone had the first problem before? 

Chris. 

-----Original Message-----
From: Renee Petris [mailto:renee@loudeye.com]
Sent: 09 October 2000 16:54
To: 'tomcat-user@jakarta.apache.org'
Subject: RE: jar's still not picked up in WEB-INF/lib


I have encountered the same problem that Barry Dunne has encountered.
However,
I am generally unable to reproduce the problem. In one case the class not
found exception went away when I provided an explicit context in
server.xml. I was using the standard webapps folder, and the context
was being automatically added by tomcat, however, the .jar files in
the WEB-INF/lib directory weren't being found by the classloader.

In another case a server running Windows NT server 4.0 had Tomcat
version 3.1 installed on it using JDK 1.3. There was no default classpath
set for the machine. We then deployed a webapp to the machine using a .war
file, and everything ran fine. We deployed several updates to the machine
using .war files each time, no new libraries were added. Then after one 
deployment, class not found exceptions started to occur. Using the same
deployment procedure to another server running the same version of Tomcat
and JDK did not produce the error. I ended up having to explicitly add
the .jar files that had been in the WEB-INF/lib directory to the 
classpath in Tomcat.bat. I have been unable to reproduce this problem
on any of our test machines, and I have been unable to get .jar
files located in the WEB-INF/lib directory on this one machine recognized.
  

-----Original Message-----
From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
Sent: Sunday, October 08, 2000 7:24 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: jar's still not picked up in WEB-INF/lib


Barry Dunne wrote:

> This problem has been posted so many times for different versions of
tomcat
> but it is still there.
>
> To summarise the problem, if you put a jar file into WEB-INF/lib you get a
> class not found exception when you try to use one of the classes from the
> jar in a servlet. However, this does not happen when you either move the
jar
> to /usr/local/tomcat/lib or extract the jar into WEB-INF/classes.
>
> Neither of these workarounds are very nice, the former makes sharing a
> server between multiple contexts/developers tricky and the latter makes a
> mess of the classes directory.
>
> There have been so many posts about this feature not working over time and
I
> have had the problem myself on linux with tomcat 3.1, 3.2 and now 4.0m1.
>

You will find that there are three fairly different classloader
implementations
(the 4.0m1 implemenation is 100% different) on these three versions -- it
certainly is not the same bug just being carried forward.

>
> This is a pretty fundemental flaw as the lib is a fairly significant part
of
> the specifications to be able to use WEB-INF/lib.
>
> Does anybody know why this problem has been left for so long now?
>
> Thanks,
> Barry.
>

The problem is that it is not just one "problem".  Classloaders are
intricate
beasts, and one of the flaws of most implementations is that you don't get
much
evidence of what's really going on when they return ClassNotFoundException.

As others have reported, putting JAR files in WEB-INF/lib works for most
people
(but not all) under 3.2b and 4.0m1 (3.1 has problems in this area that were
addressed in 3.2).  Here's a partial list of the kinds of problems that will
cause it to fail.

* Having a JAR file in *both* WEB-INF/lib and on your classpath

* Having a JAR file in *both* WEB-INF/lib and the system extensions
  classpath ($JAVA_HOME/jre/lib/ext).

* Having a class library that is on the class path and (from a
  class in that class library) trying to reference a class in the
  WEB-INF/lib area -- it's not accessible.  (This is why the
  "struts.jar" file for Struts *must* be in WEB-INF/lib and *not*
  on the classpath, for example).

* User error in untold varieties:
  - Putting ZIP files instead of JAR files in WEB-INF/lib
  - Forgetting to put the JAR file there
  - Corrupted JAR file (it will be *silently* ignored)
  - JAR file that doesn't really have the class you think it has
  - Operating system permissions problems

Given how many people have trouble getting CLASSPATHs for Java applications
and
compilation right, it's not certainly an issue that is not unique to Tomcat.

The challenge is to narrow down, in every single circumstance, exactly what
is
going on.  The requires knowing all of the following facts:
* OS and JDK versions
* If a Java2 platform, what do you have installed as system
  extensions?
* What is on your CLASSPATH (not an issue for Tomcat 4.0m1,
  which totally ignores it)?
* What libraries do you have in your $TOMCAT_HOME/lib or
  $CATALINA_HOME/lib directory?
* What libraries do you have in your WEB-INF/lib directory?
* Where was the class that threw the ClassNotFoundException
  loaded from?
* Where was the class that wasn't found supposed to be loaded
  from?

As you can see, there are many possibilities for having a problem -- and any
one
of them leads to the same symptom:  ClassNotFoundException.

You can help us narrow these things down by being tediously specific in
error
reports.  If you can create a small WAR file that reproduces the problem,
that
is absolutely the best tool for resolving things like this.

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

Mime
View raw message