Use non-default namingPolicy when creating Proxies via CGLib
------------------------------------------------------------

                 Key: WICKET-1162
                 URL: https://issues.apache.org/jira/browse/WICKET-1162
             Project: Wicket
          Issue Type: Improvement
          Components: wicket-guice
    Affects Versions: 1.3.0-rc1
         Environment: Guice 1.0,
            Reporter: uwe schaefer


As soon, as i use bindInterceptor(...) to an Instance, i run into a problem 
injecting this (CGLib enhanced) instance to a Component.

The exception thrown: 

java.lang.LinkageError: loader (instance of  
org/mortbay/jetty/webapp/WebAppClassLoader): attempted  duplicate class 
definition for name: 
"org/codesmell/jpadao/AbstractEntityDao$$FastClassByCGLIB$$aaf4cf30"
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at 
com.google.inject.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
     at 
com.google.inject.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
     at 
com.google.inject.cglib.reflect.FastClass$Generator.create(FastClass.java:64)
     at com.google.inject.cglib.proxy.MethodProxy.helper(MethodProxy.java:92)
     at com.google.inject.cglib.proxy.MethodProxy.init(MethodProxy.java:56)
     at 
com.google.inject.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:186)
     at 
com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)

I assume the problem should disappear, if LazyInitProxyFactory.createProxy(...) 
was patched like:
[...]
CGLibInterceptor handler = new CGLibInterceptor(type, locator);
Enhancer e = new Enhancer();
e.setInterfaces(new Class[] {Serializable.class, ILazyInitProxy.class,
                        IWriteReplace.class});
e.setSuperclass(type);
e.setCallback(handler);
e.setNamingPolicy(SOME_WICKET_SPECIFIC_NAMING_POLICY); // <- single new line
return e.create();
[...]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to