Skip to content

Calling to Proxy upon abstract class ends with java.lang.LinkageError: duplicate class definition [SPR-10242] #14875

@spring-projects-issues

Description

@spring-projects-issues

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:

Issue Links:

6 votes, 7 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions