Brett-
I'm trying to deploy a servlet which needs to load specific
versions of xerces.jar and xalan.jar. Tomcat 3.2.1 bundles jaxp.jar
and parser.jar under TOMCAT_HOME/lib. These XML JAR files contain packages
and classes which duplicate those in xerces.jar and xalan.jar and which
are incompatible with our versions of xerces.jar and xalan.jar.
We can modify the Tomcat CLASSPATH so our xerces.jar and xalan.jar 
occur first in the CLASSPATH (thus resolving our servlet problem in our
environment), but we are concerned that our customers will have other
servlets 
installed besides ours which require xerces.jar and xalan.jar, also, or 
some incompatible JAR files which duplicate the XML/XSLT packages/classes
we use. Their versions may differ and be incompatible with ours, and we have
no 
control over what they install. We certainly cannot modify or expect our
customers 
to modify those incompatible JAR files.

Thanks much for your help.
Barry Draper
[EMAIL PROTECTED]

-----Original Message-----
From: Brett Knights [mailto:[EMAIL PROTECTED]]
Sent: Sunday, June 03, 2001 10:09 PM
To: [EMAIL PROTECTED]
Subject: RE: Question: Tomcat 3.2.1 servlet and dynamically loading JAR
files


Barry,
What are you trying to do?

If you
a) have a bunch of jar files that contain duplicate packages and
b) want to make sure only a certain version of those classes gets used

why don't you just unjar the jar files that contain the duplicates, delete
the duplicating directories, adjust the manifest file and
re-create the jar files.

If I am correct in assuming you are having problems with all the xml files
that are duplicated in saxon, xerces, crimson, Tidy, etc.
these can be cleaned up in only a few minutes (much faster than writing
code).

If these are the packages you are dealing with and want some pointers on the
minor associated gotchas drop me a line directly (this
is OT).

I have a little app that will check the system class path for packages
duplicated in jar files. Let me know if you'd find that
helpful.

As far as your original question it isn't too difficult to write your own
classloader that would load a properties file and then
load classes from specified packages. I'd think it would be fairly easy to
subclass Tomcat's classloaders (plural since Tomcat uses
a hierarchy of classloaders) to use your definition of classpath.

HTH

***********************************************************
Brett Knights                             250-338-3509 work
[EMAIL PROTECTED]                 250-334-8309 home
***********************************************************


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, June 03, 2001 12:10 PM
> To: [EMAIL PROTECTED]
> Subject: tomcat-user Digest 3 Jun 2001 19:09:41 -0000 Issue 1128

> I have a question about loading JAR files. It is not
> necessarily specific
> to Tomcat, i.e., it is really a generic Java question,
> but my application happens to be a servlet running under Tomcat 3.2.1.
> The question is this:
> Is there a way for a servlet running under Tomcat 3.2.1 to
> dynamically load
> specific versions of JAR files independent of what is specified in the
> CLASSPATH, so that all
> references to classes implemented in these JAR files (but possibly
> implemented in
> other JAR files contained within the CLASSPATH) are guaranteed to be
> resolved
> by classes contained within the specific, dynamically loaded
> JAR files
> and not from some other JAR files specified in the CLASSPATH.
> I am looking for a Java facility for JAR files which is analogous to
> dynamically loading C and C++ libraries on
> Sun Solaris using dlopen or on Windows using the Win32 API function
> LoadLibrary.
> Can it be done with the java.lang.ClassLoader or some other standard
> classes?
> Can someone point me to some sample code which demonstrates
> how to do this?

Reply via email to