Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Overriding packages exposed by org.eclipse.osgi
Overriding packages exposed by org.eclipse.osgi [message #903568] Fri, 24 August 2012 11:28 Go to next message
Kevin Milburn is currently offline Kevin MilburnFriend
Messages: 13
Registered: July 2012
Junior Member
I need to use Xerces 2.11.0 in an RCP application, which requires updated versions of the javax.xml and org.w3c.dom pacakges, but attempting to use them is causing problems.

If I add Xerces and xml-apis bundles to my plugin, I can use the correct Xerces parser, but it ultimately fails with:
java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
This fails because, the ClassLoader is attempting to find the class in org.eclipse.osgi, which as it draws from the Java runtime (JavaSE 1.7), does not have it.

I've tried overriding the org.osgi.framework.bootdelegation property to prevent some exposure of the packages, which is partially successful. However, if I get my plugin to use my xml-apis bundle first, it then fails with
java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "org/w3c/dom/Document"

If I attempt to remove the packages from org.osgi.framework.system.packages the app won't start as other parts of the system don't know about my xml-apis bundle. Is there any to do so?

I've also tried adding Xerces to the endorsed libs, this is mostly successfull, but appears to break parts of the WTP, and it doesn't feel right to have to do this in the OSGi world.

Is there some other way to get this to work that I've missed, or any other pointers that could help?

TIA

Edit: changing the org.osgi.framework.bootdelegation wasn't necessary, just putting the xml-apis bundle before org.eclipse.core.runtime is enough to trigger the LinkageError.

[Updated on: Fri, 24 August 2012 12:26]

Report message to a moderator

Re: Overriding packages exposed by org.eclipse.osgi [message #903639 is a reply to message #903568] Fri, 24 August 2012 15:44 Go to previous messageGo to next message
Martin Skorsky is currently offline Martin SkorskyFriend
Messages: 112
Registered: July 2009
Senior Member
You can use Require-Bundle for the Xerces bundle with a version range [2.11.0,3.0.0).

If the Xerces bundle exports the packages with version 2.11, you can alternatively use Import-Package with a version range.
Re: Overriding packages exposed by org.eclipse.osgi [message #904538 is a reply to message #903639] Tue, 28 August 2012 16:28 Go to previous message
Kevin Milburn is currently offline Kevin MilburnFriend
Messages: 13
Registered: July 2012
Junior Member
In my plugin I do have the Required-Bundle on the appropriate versions of the Xerces and xml-apis bundles, but it turns out the problem was that the Xerces bundles didn't have the xml-apis as a required bundle.

While this solves the problem with using Xerces directly, a third party bundle doesn't explicity require Xerces, but does implicitly rely on the latest xml-apis, as such I can't modify its Required Bundles (without resorting to repackaging it). One trick I have found that appears to resolve this is adding the xml-apis bundle to the osgi.framework.extension property, but that feels a bit hacky.
Previous Topic:Adding items to subment 'New' in eclipse cnf
Next Topic:Content assist does not scroll
Goto Forum:
  


Current Time: Thu Apr 25 17:28:44 GMT 2024

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

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

Back to the top