Aron,
Based on the stack trace alone it's difficult to debug the problem.
If you want everything to be self contained within your context,
then the first thing I would ensure is that every class required
by your servlet is contained with the classes or lib directory
of your context.
Also, since the system classloader is used prior to your
webapp's classloader, ensure that your system
classpath is clean to avoid inadvertent loading of classes.
Ideally this is all you would have to do.
As a long shot, I've run into the following gotcha which may
apply to xml4j.
I've run into problems with code that attempts to grab
the current classloader in the following way:
Object object = new Object();
ClassLoader loader = object.getClass().getClassLoader();
I've found that the classloader retrieved in this manner is
unable to load classes from within my context. My rationale
for this is because java.lang.Object is loaded and instantiated
via the system classloader, and thus the system classloader is
returned.
Instead you want to do something like:
ClassLoader loader = getClass().getClassLoader();
which should return your webapp's classloader.
Hopefully this helps.
Rob
----- Original Message -----
From: "Aron Kramlik" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 05, 2000 8:36 PM
Subject: RE: Class loading & classloader visibility test results
> Rob,
>
> This is great information. I wonder if you could explain
> why it is that I need to put xml4j.jar file under the $CLASSPATH
> (i.e. $TOMCAT_HOME/lib) that is loaded by an init() method of
> a servlet?
>
> Once I do this the class, com.ibm.xml.parsers.DOMParser, is found.
> Stack trace below.
>
> Anyh help would be much appreciated.
>
> Thanks again for the great info,
> Aron.
>
> java.lang.ClassNotFoundException: com.ibm.xml.parsers.DOMParser
> at java.lang.Throwable.<init>(Throwable.java:96)
> at java.lang.Exception.<init>(Exception.java:44)
> at
> java.lang.ClassNotFoundException.<init>(ClassNotFoundException.java:71)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
> at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:380)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:257)
> at java.lang.Class.forName1(Native Method)
> at java.lang.Class.forName(Class.java:134)
> at org.xml.sax.helpers.ParserFactory.makeParser(ParserFactory.java:124)
> at com.tenzing.servlet.InitServlet.setXMLParser(InitServlet.java:331)
> at
> com.tenzing.servlet.InitServlet.initializeConfiguration(InitServlet.java:298
> )
> at com.tenzing.servlet.InitServlet.init(InitServlet.java:181)
> at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
>
>
>
>
> -----Original Message-----
> From: Rob Shaw [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 05, 2000 2:49 PM
> To: [EMAIL PROTECTED]
> Subject: Class loading & classloader visibility test results
>
>
> For those that may be interested...
>
> I was unclear as to how Tomcat was resolving class
> loading and the visibility of classes to a context's
> classloader so I created a simlpe test suite.
> The test results are attached.
>
> Rob Shaw
> Servidium Inc.