Send reply to:          [EMAIL PROTECTED]
Subject:                Re: SAX parser class loading
To:                     [EMAIL PROTECTED]
From:                   [EMAIL PROTECTED]
Date sent:              Thu, 16 May 2002 19:00:24 -0400

> Let me see if I can summarize where we're at here (and explain to myself
> why Rob's code works for him if Edwin's right about what's going on). 
> If
> Rob's on a Sun JDK 1.4.x and doesn't use the endorsed standards override
> mechanism, he should break if Edwin's right because he'll pick up
> Crimson's
> JAXP/SAX factories before his hacked Xerces libs, and the crimson
> factories
> will still refuse to do anything but look at the context class loader.
> 

Ok - let me explain this one more time for those that are still struggling with 
it. 
There is nothing "hacked" about the Xerces lib we are using. It is the standard 
JAR downloaded from the Apache site - we haven't ever rebuilt it, in fact we 
only 
got the source code to figure it why we were having problems.

What is different about it is that it is NOT on the classpath - it is embedded 
as an 
inner JAR within a JAR and loaded via a custom classloader (i.e. the OSGi 
classloader - which makes it possible to have classes loaded from within an 
inner 
JAR)

When the Xerces factory method uses 
Thread.currentThread.getContextClassloader() to try and find the classloader to 
use to create a new SAX parser instance it will fallback to the system 
classloader 
if no specific classloader has been set for the current thread (i.e whoever 
created 
the thread didn't call setContextClassloader() after they created the thread). 
This 
will fail, because the Xerces JAR is not on the classpath and attempts to use 
the 
system classloader to load it's classes will fail. The workaround is after this 
fails 
to try getClass().getClassloader() next, which will then find the custom 
classloader which  will then successfully find and instantiate the SAX parser.

-- Rob

SoftSell Business Systems, Ltd.
' testing solutions for a changing world '
 
+44 (20) 7488 3470
www.softsell.com
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to