Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Technology Project and PMC » Classloader conflicts with JAXP in plugin using Xalan
Classloader conflicts with JAXP in plugin using Xalan [message #48877] Wed, 12 March 2003 22:49 Go to next message
Eclipse UserFriend
Originally posted by: pnehrer.freeshell.org

Hi, I'm writing a search plugin that uses Xalan to perform some
transformations (during the course of the search). The actual
transformation is encapsulated in a class/method outside of the plugin
package (but is part of the plugin project and jar). Initially I
provided my own xalan.jar, xml-apis.jar, and xercesImpl.jar as a runtime
dependency. My unit test works fine (i.e., performs a transformation OK,
running as a standalone Java app using the same classpath as used by the
plugin). However, I get classloader exceptions trying to use it from
within my plugin; some of the JAXP classes are already loaded by the
classloader. Fine, I removed the conflicting classes from my
xml-apis.jar and got rid of xercesImpl.jar (which was also conflicting
w/ Xerces used by Eclipse). Now, however, Xalan reports validation
exceptions when loading the stylesheet (I suspect this version of Xalan
doesn't agree w/ the version of Xerces used by Eclipse).

Is there a way to avoid these conflicts? Can my plugin get a "private"
classloader and thus its own versions of these (JAXP and Xerces)
classes? Is this because the code that tries to do this is run from the
Search Dialog?

I'd appreciate if anyone could shed some light on this. What are the
Eclipse rules regarding class loaders? This topic is a nightmare in Ant,
especially in taskdefs dealing w/ XML/JAXP. Thank you!
--Peter
Re: Classloader conflicts with JAXP in plugin using Xalan [message #49026 is a reply to message #48877] Thu, 13 March 2003 02:33 Go to previous message
Eclipse UserFriend
Originally posted by: pascal_rapicault.yahoo.fr

For the classloader, there is only one magic formula to know:
PSP

Platform (boot) / Self (all the jars and classes you provide) /
Prerequisite(you prerequisite)

This formula states the order in which the classloader will be examined
to find a given class. Note that this is recursive: P S (P S (P ...))

Note that fragments are their jars to the Self of the plugin they "extend".

For your specific problem you can either include all your libraries into
your plugin, so you will always find the xerces classes you provide.
But be careful not to let some of the xerces instances go outside of
the plugin or you may end up with ClassCastException.

A more "elegant" solution would consist in
creating a Xalan fragment to xerces so that you always get the
same class instance although the same classes may appear several
times in different jars.

Hope this help.

Sincerely

PaScaL





"Peter Nehrer" <pnehrer@freeshell.org> a
Re: Classloader conflicts with JAXP in plugin using Xalan [message #591596 is a reply to message #48877] Thu, 13 March 2003 02:33 Go to previous message
Pascal Rapicault is currently offline Pascal RapicaultFriend
Messages: 440
Registered: July 2009
Senior Member
For the classloader, there is only one magic formula to know:
PSP

Platform (boot) / Self (all the jars and classes you provide) /
Prerequisite(you prerequisite)

This formula states the order in which the classloader will be examined
to find a given class. Note that this is recursive: P S (P S (P ...))

Note that fragments are their jars to the Self of the plugin they "extend".

For your specific problem you can either include all your libraries into
your plugin, so you will always find the xerces classes you provide.
But be careful not to let some of the xerces instances go outside of
the plugin or you may end up with ClassCastException.

A more "elegant" solution would consist in
creating a Xalan fragment to xerces so that you always get the
same class instance although the same classes may appear several
times in different jars.

Hope this help.

Sincerely

PaScaL





"Peter Nehrer" <pnehrer@freeshell.org> a
Previous Topic:Viewing Simple HTML in SWT
Next Topic:Viewing Simple HTML in SWT
Goto Forum:
  


Current Time: Sat Jul 27 12:39:10 GMT 2024

Powered by FUDForum. Page generated in 0.03760 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top