I was testing the CompiledApplet sample code from the DTM branch. I
deployed it in Tomcat 4.1.18 and I used the Sun JRE 1.4.* as my IE 5.5 Java
Plugin runtime environment. When I tested CompiledApplet sample, I got
java.lang.IllegalAccessError: class
org.apache.xalan.xsltc.dom.SAXImpl$TypedNamespaceIterator cannot access its
superclass org.apache.xml.dtm.ref.DTMDefaultBaseIterators$NamespaceIterator
Cause of an old version of Xalan is bundled with Sun JDK 1.4.*. Using the
"Endorsed Standards Override Mechanism", I copied a newer version of
Xalan.jar in the /lib/endorsed directory. The story starts from here,

Referring back to previous discussions about  Xalan generalized
ClassLoading Mechanism.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16675
I modified the code and use the ObjectFactory class to load the translet
class in org.apache.xalan.xsltc.trax.TransformerFactoryImpl .

The very first time, I access my applet from IE. According to the Applet
lifecycle, its init() and start() methods are invoked by the JVM. The
getContextClassLoader() returns sun.plugin.security.PluginClassLoader and
the getSystemClassLoader() returns sun.misc.Launcher$AppClassLoader. The
ObjectFactory.findClassLoader() method will return
sun.plugin.security.PluginClassLoader as the class loader to load the
translet class. The translet class is in a jar file which specified in the
applet archive attribute. I get the right result.

Subsequently, I click "Run" in the menu.html which uses Javascript to call
the transform() method of my applet. It is where I get
javax.xml.transform.TransformerConfigurationException: Cannot find class
****

This time, the getContextClassLoader() returns null, cause the applet
lifecycle methods (init, start, stop, destroy) and the transform() method
are running in different threads. The contextclassloader for transform()
method has no knowledge about the classes were loaded from the codebase or
archive. In this case, ObjectFactory.class.getClassLoader() in
ObjectFactory.findClassLoader() returns null too, cause of the xalan.jar in
the endorsed directory is loaded by the bootstrap class loader. So the
systemClassLoader ( sun.misc.Launcher$AppClassLoader) is returned. Of
cause, it has no information about my translet class. Then the
ObjectFactory.findProviderClass() method uses the fallback and tries to
load translet class by using Class.forName(classname) . It tries to load
the translet class from the current loader which is null.

Now, you can tell why I got Cannot find class error. My questions are:
1. Did I use the right way to replace the bundled xalan ?
2. Is there anyway that I can get the right ContextClassLoader from
Applets. (without using setContextClassLoader)
3. Is ObjectFactory sophisticated enough?

Sorry for this long mail, I hope that I explained my problems well enough.

Christine Li
XSLT Development
IBM Toronto Lab
Tel: (905)413-2601
Email: [EMAIL PROTECTED]

Reply via email to