Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Classloader problems when bundling CGLIB as plugin
Classloader problems when bundling CGLIB as plugin [message #461312] Tue, 09 January 2007 09:46 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi all,

Since our application needs to generate proxy classes at runtime I bundled
CGLIB as plugin. Hence our application consists of the following plugins :

1. Plugin A is CGLIB plugin.
2. Plugin B contains superclass of the new proxied classes.
3. Plugin C contains interfaces classes to be implemented by the proxy.

Here's what I put in the MANIFEST.MF of each plugin :

- Plugin A:
Eclipse-BuddyPolicy: registered

- Plugin B:
Require-Bundle: net.sf.cglib

- Plugin C:
Eclipse-RegisterBuddy: net.sf.cglib

This is the actual code that does the proxying :

...
Enhancer e = new Enhancer();
e.setSuperClass(superClass);
e.setInterfaces(new Class[]{interfaceClass});
e.setCallback(callback);
Object o = e.create();
...

At runtime the above code produces NoClassDefFoundError for unable to find
the interface class.

Then I tell CGLIB to use interface class classloader :

...
Enhancer e = new Enhancer();
e.setClassLoader(interfaceClass.getClassLoader());
...

This produces NoClassDefFoundError for unable to find
net.sf.cglib.proxy.Factory class.

I also try to use context classloader :

...
Enhancer e = new Enhancer();
e.setClassLoader(Thread.currentThread().getContextClassLoade r());
...

This time produces NoClassDefFoundError for unable to find the superclass.

In summary we need to resolve the following classes's classloader :

1. CGLIB.
2. Interface classes.
3. Superclass.
4. Proxied class.

What classloader should I use to resolve the above classes ?

Have anybody experienced the following problems ?

Any help would be greatly appreciated.

Best Regards,

Setya
Re: Classloader problems when bundling CGLIB as plugin [message #461342 is a reply to message #461312] Tue, 09 January 2007 14:57 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Setya wrote:
> Hi all,
>
> Since our application needs to generate proxy classes at runtime I
> bundled CGLIB as plugin. Hence our application consists of the following
> plugins :
>
> 1. Plugin A is CGLIB plugin.
> 2. Plugin B contains superclass of the new proxied classes.
> 3. Plugin C contains interfaces classes to be implemented by the proxy.
>
> Here's what I put in the MANIFEST.MF of each plugin :
>
> - Plugin A:
> Eclipse-BuddyPolicy: registered
>
> - Plugin B:
> Require-Bundle: net.sf.cglib
>
> - Plugin C:
> Eclipse-RegisterBuddy: net.sf.cglib
>
> This is the actual code that does the proxying :
>
> ..
> Enhancer e = new Enhancer();
> e.setSuperClass(superClass);
> e.setInterfaces(new Class[]{interfaceClass});
> e.setCallback(callback);
> Object o = e.create();
> ..


Where is this code? Which plugin? And which plugin is it called from?

Later,
PW


Re: Classloader problems when bundling CGLIB as plugin [message #461372 is a reply to message #461342] Wed, 10 January 2007 09:15 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Paul Webster wrote:
>> 1. Plugin A is CGLIB plugin.
>> 2. Plugin B contains superclass of the new proxied classes.
>> 3. Plugin C contains interfaces classes to be implemented by the proxy.
>>
>> Here's what I put in the MANIFEST.MF of each plugin :
>>
>> - Plugin A:
>> Eclipse-BuddyPolicy: registered
>>
>> - Plugin B:
>> Require-Bundle: net.sf.cglib
>>
>> - Plugin C:
>> Eclipse-RegisterBuddy: net.sf.cglib
>>
>> This is the actual code that does the proxying :
>>
>> ..
>> Enhancer e = new Enhancer();
>> e.setSuperClass(superClass);
>> e.setInterfaces(new Class[]{interfaceClass});
>> e.setCallback(callback);
>> Object o = e.create();
>> ..
> Where is this code? Which plugin? And which plugin is it called from?

Sorry for the missing information, I also want to add minor correction.

1. The code resides in plugin B.
2. The code is called from plugin C.
2. Plugin B does not actually contain the superclass, but the superclass
resides in plugin D which is 'required' by plugin B.

So, in summary here's the correct architecture :

1. Plugin A is CGLIB plugin.
2. Plugin B contains contains code that generates new proxied class.
3. Plugin C contains interface classes to be implemented by the proxied
class.
4. Plugin D contains superclass.


Manifest.MF :
=============

Plugin A:
---------
Bundle-SymbolicName: net.sf.cglib
Eclipse-BuddyPolicy: registered

Plugin B:
---------
Bundle-SymbolicName: plugin.b
Require-Bundle: net.sf.cglib, plugin.d
Eclipse-BuddyPolicy: registered

Plugin C:
---------
Bundle-SymbolicName: plugin.c
Require-Bundle: plugin.b
Eclipse-RegisterBuddy: net.sf.cglib, plugin.b

Plugin D:
---------
Bundle-SymbolicName: plugin.d
Export-Package: package.that.contains.superclass



Best Regards,


Setya
Re: Classloader problems when bundling CGLIB as plugin [message #461525 is a reply to message #461372] Thu, 11 January 2007 10:50 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
>>> This is the actual code that does the proxying :
>>>
>>> ..
>>> Enhancer e = new Enhancer();
>>> e.setSuperClass(superClass);
>>> e.setInterfaces(new Class[]{interfaceClass});
>>> e.setCallback(callback);
>>> Object o = e.create();
>>> ..

> 1. The code resides in plugin B.
> 2. The code is called from plugin C.
> 2. Plugin B does not actually contain the superclass, but the superclass
> resides in plugin D which is 'required' by plugin B.

> So, in summary here's the correct architecture :

> 1. Plugin A is CGLIB plugin.
> 2. Plugin B contains contains code that generates new proxied class.
> 3. Plugin C contains interface classes to be implemented by the proxied
> class.
> 4. Plugin D contains superclass.


> Manifest.MF :
> =============

> Plugin A:
> ---------
> Bundle-SymbolicName: net.sf.cglib
> Eclipse-BuddyPolicy: registered

> Plugin B:
> ---------
> Bundle-SymbolicName: plugin.b
> Require-Bundle: net.sf.cglib, plugin.d
> Eclipse-BuddyPolicy: registered

> Plugin C:
> ---------
> Bundle-SymbolicName: plugin.c
> Require-Bundle: plugin.b
> Eclipse-RegisterBuddy: net.sf.cglib, plugin.b

> Plugin D:
> ---------
> Bundle-SymbolicName: plugin.d
> Export-Package: package.that.contains.superclass


Well, anybody has the same problem with cglib as plugin before ?


Regards,


Setya
Re: Classloader problems when bundling CGLIB as plugin [message #461542 is a reply to message #461372] Thu, 11 January 2007 17:45 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Setya wrote:
> Plugin D:
> ---------
> Bundle-SymbolicName: plugin.d
> Export-Package: package.that.contains.superclass
>


How is plugin C supposed to be able to see the superclass? It looks
like its hidden behind plugin B (which can see it from plugin D).

I'm not sure which part is causing your problem, though.

Later,
PW


Re: Classloader problems when bundling CGLIB as plugin [message #462032 is a reply to message #461542] Mon, 22 January 2007 16:37 Go to previous message
Nik Bhattacharya is currently offline Nik BhattacharyaFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Setya,

Did you ever resolve this problem? Curious to know what you did. I was
playing with the buddy classloading system and was getting a
noclassdeffound error as well.

Have you tried simply accessing a dummy static method from Plugin D in
your Plugin B code? Are you able to see any classes at runtime from
Plugin D (accessed from plugin B)?

- Nik



Paul Webster wrote:
> Setya wrote:
>> Plugin D:
>> ---------
>> Bundle-SymbolicName: plugin.d
>> Export-Package: package.that.contains.superclass
>>
>
>
> How is plugin C supposed to be able to see the superclass? It looks
> like its hidden behind plugin B (which can see it from plugin D).
>
> I'm not sure which part is causing your problem, though.
>
> Later,
> PW
Previous Topic:PreferenceConverter throws Exception
Next Topic:XML Editor problem
Goto Forum:
  


Current Time: Sun Sep 08 20:51:35 GMT 2024

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

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

Back to the top