Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse RT (runtime) » Classloading: Unable to load class of a dependent plugin from a java project(Unable to load class of a dependent plugin from a java project whose packages are exported for this plugin)
Classloading: Unable to load class of a dependent plugin from a java project [message #667206] Wed, 27 April 2011 12:29
nitu  is currently offline nitu Friend
Messages: 3
Registered: April 2011
Junior Member
Below is the description and the structure of my project and plug-ins code base.

1. A java project named 'SampleProject' having package 'com.sample.action'.
2. A plug-in project named 'SamplePluginA' having reference of above java project's jar file which is set as Bundle-ClassPath also.
3. A plug-in project named 'SamplePluginB' having reference of the exported package 'sample.action' from 'SamplePluginA' for 'SampleProject'.

Now, at runtime execution of the plug-in 'SamplePluginB', the class 'sample.action.A' of 'SampleProject' is invoked which tries to load the class 'B' located under the 'SamplePluginB'. While loading this class, it throws the ClassCastException because the class loaders for both the classes differs. Whereas, if 'sample.action.A' tries to load a class located under the 'SampleProject' then it succeeds.

The configuration in the respective MANIFEST.MF is done as follows:

1. MANIFEST.MF of SamplePluginA has the entry for SampleProject.jar:

Bundle-ClassPath: lib/SampleProject.jar
Export-Package: sample.action.A;x-friends:="SamplePluginB"

2. of SamplePluginA has the entry:
bin.includes = lib/SampleProject.jar
jars.extra.classpath = lib/SampleProject.jar

3. MANIFEST.MF of SamplePluginB has the entry:
Require-Bundle: com.sample.samplepluginA;bundle-version="1.0.0″

The Class B is the implementation of an interface that belongs to SampleProject and a Decorator is implemented which tried to load implementor classes of this interface which are registered within the chain. This chain is build by the builder class located under the SamplePluginB.

I have tried to load the Class B from the Class located under the SampleProject by the ClassLoader object obtained from the Activator class of the SamplePluginB. This approach works fine because the class will always be loaded from its class loader. But, i need a way where i dont need to pass a ClassLoader to my core class.

I would also like to know whether am i missing any configuration in the plugin.xml or have i made mistake by creating SamplePluginB as a plugin and i would have created it as a fragment?

Thanks & Regards,
Previous Topic:Issue accesing a JAR file inside a plugin
Next Topic:how to resolve a deadlock issue.
Goto Forum:

Current Time: Sat Dec 05 00:32:38 GMT 2020

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

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

Back to the top