You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Ari Halberstadt <ar...@shore.net> on 1999/12/19 02:49:00 UTC
class loading troubles
Two problems related to class loading.
The first problem has to do with NoClassDefFoundErrors. I've added a web
application to tomcat with the following lines in server.xml:
<Context path="/photography/photodb" docBase="photography/photodb"
defaultSessionTimeOut="30" isWARExpanded="true"
isWARValidated="false" isInvokerEnabled="true"
isWorkDirPersistent="false"/>
In photography/photodb there's a web.xml file. If I unjar all of the
classes into photography/photodb/classes then tomcat is able to compile the
.jsp's into .java and then into .class files. But, when I try to access the
jsp page I get a java.lang.NoClassDefFoundError. The exception is thrown on
a class that is clearly present in the import list. So, at compile time the
classpath used by tomcat must be correct, but at page serve time the
classpath seems to be missing some of my classes. The really odd thing is
that some of the classes in the same class hierarchy are accessible to
tomcat, while others are not (e.g., com.magiccookie.photodb.PhotoRequest is
accessible but com.magiccookie.photodb.Folder is not).
The second problem is how to get tomcat to find classes in .jar files in
the WEB-INF/lib directory. If I archive my classes into .jar files in the
WEB-INF/lib for my web application then I get a whole bunch of class not
found errors when tomcat tries to compile the .jsp files. The same jsp
files compile ok if I unjar the class files into the expanded
WEB-INF/classes directory. It seemed to me that the isWARExpanded property
would be a good candidate, but setting this to false does not get tomcat to
load the files from the WEB-INF/lib directory.
The jsp and servlet examples supplied with tomcat seem to work ok, and a
simple jsp file--it doesn't use any of my classes--in my web application
also loads ok.
To summarize, my questions are:
1. How to deal with the NoClassDefFoundError errors?
2. How to get tomcat to load classes in jar files in WEB-INF/lib?
3. Is there any documentation yet for the server.xml file?
System: i686, Linux 2.2.13-7mdk, glibc-2.1.2-8mdk, ibm jdk 1.1.8, tomcat 3.0
(I've tried blackdown jdk1.1.7v3 with the same results while blackdown
jdk1.2rc3 bombs.)
-- Ari Halberstadt mailto:ari@shore.net <http://www.magiccookie.com/>
Re: class loading troubles
Posted by Ari Halberstadt <ar...@shore.net>.
I wrote:
>...
>The first problem has to do with NoClassDefFoundErrors.
>...
Answering one's own questions seems silly, but at least I've figured out
the answer to my first question as to why I was getting these exceptions. I
had forgotten to add Sun's collections classes to tomcat's classpath, so of
course it couldn't instantiate classes that depended on the collections
classes. Compilation succeeded because the collections classes were only
being referenced in regular .java source files, and I had setup the
classpath correctly for the compiler. This came to light when I tried
hitting another page and got a more useful error message indicating which
classes were missing.
The other two questions (questions 2 and 3) remain unanswered.
>...
>To summarize, my questions are:
>
>1. How to deal with the NoClassDefFoundError errors?
>
>2. How to get tomcat to load classes in jar files in WEB-INF/lib?
>
>3. Is there any documentation yet for the server.xml file?
-- Ari Halberstadt mailto:ari@shore.net <http://www.magiccookie.com/>