-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Jan Novotný opened SPR-10242 and commented
In 3.2 GA version of the Spring Framework I started to experience LingageErrors with cause of duplicate class definition. For example:
net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:64)
at net.sf.cglib.proxy.MethodProxy.helper(MethodProxy.java:120)
at net.sf.cglib.proxy.MethodProxy.init(MethodProxy.java:74)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:213)
at com.fg.metadata.business.aop.SpringCgLibIssue$AbstractMethodInterceptor.intercept(SpringCgLibIssue.java:58)
at com.fg.metadata.business.aop.SpringCgLibIssue$TestClassToProxy$$EnhancerByCGLIB$$f3b6125d.getSomeInt(<generated>)
at com.fg.metadata.business.aop.SpringCgLibIssue$TestClassToProxy$$FastClassByCGLIB$$4b5eb31.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at com.fg.metadata.business.aop.SpringCgLibIssue$SomeAdvice.invoke(SpringCgLibIssue.java:71)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at com.fg.metadata.business.aop.SpringCgLibIssue$TestClassToProxy$$EnhancerByCGLIB$$d3d37a7d.getSomeInt(<generated>)
at com.fg.metadata.business.aop.SpringCgLibIssue.testCallMethodOfAbstractClass(SpringCgLibIssue.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:139)
at com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTestRunner.java:52)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
... 36 more
Caused by: java.lang.LinkageError: duplicate class definition: com/fg/metadata/business/aop/SpringCgLibIssue$TestClassToProxy$$FastClassByCGLIB$$4b5eb31
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
... 42 more
Problem can be reproduced by the attached TestCase. Problem is quite weird - and is described in the attached test. Only first call to the implemented method of the abstract class ends with this exception, all succeeding calls finish ok.
Please don't ask why we are wrapping CgLib proxy into another Spring proxy. We have our reasons that are quite complex to explain.
This problem did not occur in previous versions of Spring (we use this mechanism since 2.5 version of Spring).
Thanks for help in advance.
Affects: 3.2 GA
Attachments:
- SpringCgLibIssue.java (2.68 kB)
Issue Links:
- aop:scoped-proxy may fail with LinkageError: loader attempted duplicate class definition for name [SPR-11398] #16025 aop:scoped-proxy may fail with LinkageError: loader attempted duplicate class definition for name
6 votes, 7 watchers