Classloader problems when bundling CGLIB as plugin [message #461312] |
Tue, 09 January 2007 09:46 |
|
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 |
|
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
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Re: Classloader problems when bundling CGLIB as plugin [message #461372 is a reply to message #461342] |
Wed, 10 January 2007 09:15 |
|
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 |
|
>>> 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03876 seconds