Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » [SOLVED] Class Loader problem with batik: How to search dependencies ?(batik class org/w3c/dom/DOMImplementation is read two times in the same plugin and not with the same ClassLoader)
[SOLVED] Class Loader problem with batik: How to search dependencies ? [message #931810] Wed, 03 October 2012 10:49 Go to next message
Christophe Becavin is currently offline Christophe Becavin
Messages: 18
Registered: April 2011
Location: France
Junior Member
Hello,

I have been trying to integrate an SVG export in my Eclipse RCP software, but I have a problem when running the code:

!ENTRY org.eclipse.ui 4 0 2012-10-03 16:39:44.835
!MESSAGE Unhandled event loop exception
!STACK 0
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/DOMImplementation"
	at bob.ImageExportUtils.exportAWTasSVG(ImageExportUtils.java:51)
	at bob.HeatMapView.widgetSelected(HeatMapView.java:692)
	...


For running my software and have no problem with external jar files, I inserted all of them in a plugin bob.lib, created using the wizard "Plugin from jar files". This plugin is the only dependencies declared for my bob plugin (excepted of course the different org.eclipse.* plugin always needed)

I guess my problem come from the fact that bob.lib plugin contains different type of jar, and maybe two of them have both implemented org.w3c.dom.DOMImplementation, so a conflict is reached has the ClassLoader try to re-load an existing class.

I admit that the concept of ClassLoader is for me totally virtual (I understand the concept but never go in the deep code), so if you have a hint on my problem and know how to solve it using a specific Eclipse tool, like searchning in a plugin who is using a specific class, I would be pleased to hear it !

Thank you.

[Updated on: Tue, 16 October 2012 11:06]

Report message to a moderator

Re: Class Loader problem with batik: How to search dependencies ? [message #932298 is a reply to message #931810] Wed, 03 October 2012 21:52 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan Herrmann
Messages: 999
Registered: July 2009
Senior Member
When you select your project bob and do Navigate > Open Type (Shift-Ctrl-T) and type the name of the class in question, do you see multiple occurrences?
Re: Class Loader problem with batik: How to search dependencies ? [message #932724 is a reply to message #932298] Thu, 04 October 2012 07:17 Go to previous messageGo to next message
Christophe Becavin is currently offline Christophe Becavin
Messages: 18
Registered: April 2011
Location: France
Junior Member
No only one file... (see attached)

So it is definitely a problem of ClassLoader ? I found one day on a forum someone explaining that you can ask for a class to be loaded by a different ClassLoader than the rest of the project. But I cannot find it today.
Re: Class Loader problem with batik: How to search dependencies ? [message #933002 is a reply to message #932724] Thu, 04 October 2012 12:42 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan Herrmann
Messages: 999
Registered: July 2009
Senior Member
Alright, so your project seems to be configured alright and the only type of that name comes right from the JRE, not any user library.
I'm not sure if classes from the JRE should actually be loaded by the DefaultClassLoader, but that question would best be answered by some Equinox folks at http://www.eclipse.org/forums/index.php/f/31/
Re: Class Loader problem with batik: How to search dependencies ? [message #933724 is a reply to message #933002] Fri, 05 October 2012 05:26 Go to previous messageGo to next message
Christophe Becavin is currently offline Christophe Becavin
Messages: 18
Registered: April 2011
Location: France
Junior Member
Ok thanks for your help I'll see with them.

[Edit] Post created: http://www.eclipse.org/forums/index.php/m/933728/#msg_933728

[Updated on: Fri, 05 October 2012 05:33]

Report message to a moderator

Re: Class Loader problem with batik: How to search dependencies ? [message #946850 is a reply to message #933724] Tue, 16 October 2012 11:06 Go to previous message
Christophe Becavin is currently offline Christophe Becavin
Messages: 18
Registered: April 2011
Location: France
Junior Member
For those who might be interested, I solved my problem by using another class.

Apprently it was not org.w3c.dom posing problem but org.apache.batik.dom which is loaded when using GenericDOMImplementation in the code:
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
Document document = domImpl.createDocument(null, "svg", null);

Both package might use different ClassLoader

In fact, packages needed are now in the TargetPlatform apparently by default (Eclipse 4.2) :
org.apache.batik.dom
org.apache.batik.svggen
org.apache.batik.ext.awt

Using these, instead of Batik exported packages solves the problem.

So Batik has a special way of managing ClassLoader ? Is it even possible ?

Anyway it is working, I can do nice figures and that's the principal for me Very Happy
Previous Topic:[APT] Annotation Processor - java.lang.NoClassDefFoundError: javax/persistence/Column
Next Topic:Need Help getting Hello Program on screen
Goto Forum:
  


Current Time: Fri Aug 29 12:16:55 EDT 2014

Powered by FUDForum. Page generated in 0.02113 seconds