java.lang.LinkageError [message #103926] |
Wed, 16 January 2008 08:39  |
Eclipse User |
|
|
|
Originally posted by: ysralmasri.yahoo.com
Hello,
I'm using 3 bundles A B & C. A is the core bundle that contains all
necessary libs, and it takes care of exporting any packages needed by
other bundles. All my logic resides in B, and C is merely an activator
that looks up services and calls methods on B.
In B I have the following method:
public Document parseXMLString(String aXMLStr) throws ParseException {
log.debug("XML to be parsed is : " + aXMLStr);
DOMParser parser = new DOMParser();
try {
log.debug("Started parsing");
StringReader strReader = new StringReader(aXMLStr);
InputSource inputSource = new InputSource(strReader);
parser.parse(inputSource);
log.debug("Parsing finished");
strReader.close();
} catch (IOException ex) {
throw new ParseException("IO Exception", ex);
} catch (SAXException saxEX) {
throw new ParseException("Parse Exception", saxEX);
}
return parser.getDocument();
}
Now A contains sax.jar, dom.jar and jaxp-api.jar that has all XML related
stuff, and B has org.xml.sax, org.w3c.dom in its Import-Package part.
When my code runs, I have the following exception:
java.lang.LinkageError: loader constraints violated when linking
org/xml/sax/InputSource class
pointing to the line: parser.parse(inputSource)
I know that this package also exists in the JDK so it's mixed up on it as
to where to get this class from.
I tried to get rid of sax.jar and remove it from A's class path so to
convince B to get org.xml.sax.* from the JDK itself. But now I got the
following error:
java.lang.LinkageError: loader constraints violated when linking
org/w3c/dom/Document class
pointing to return parser.getDocument();
That's an expected result, and the first thing one will think of is
getting rid of dom.jar!
When I did that, I have compile error saying that:
The type org.w3c.dom.ranges.DocumentRange cannot be resolved. It is
indirectly referenced from required .class files
It's pointing to a class in bundle B.
Here I'm stuck; org.w3c.dom.ranges package just doesn't exist in the JDK
and it's only there in the dom.jar.
Any thoughts?
|
|
|
|
|
|
Re: java.lang.LinkageError [message #104697 is a reply to message #104615] |
Mon, 04 February 2008 02:04  |
Eclipse User |
|
|
|
Originally posted by: ysralmasri.yahoo.com
Hello Yubo,
Both Import-Package and Export-Package support version numbers in their
syntax. When you go to Dependencies tab and press "Add..." button in
Imported Packages you should find a version number next to any package
that was exported with a version. You can also include this manually (you
don't need to) by editing the manifest file.
-Yasser
|
|
|
Powered by
FUDForum. Page generated in 0.19430 seconds