Skip to content

Error When Proxying PersistenceBrokerDaoSupport [SPR-357] #5087

Closed
@spring-projects-issues

Description

@spring-projects-issues

Rob Harrop opened SPR-357 and commented

When trying to proxy a subclass of PersistenceManagerDaoSupport the following error is generated when using CGLIB proxies:

net.sf.cglib.core.CodeGenerationException: java.lang.IllegalArgumentException-->Protected method: createPersistenceBrokerTemplate()Lorg/springframework/orm/ojb/PersistenceBrokerTemplate;
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:566)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:493)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:368)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:280)
at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:171)
at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:136)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:66)
at com.apress.prospring.ch14.timer.Foo.main(Foo.java:25)
Caused by: java.lang.IllegalArgumentException: Protected method: createPersistenceBrokerTemplate()Lorg/springframework/orm/ojb/PersistenceBrokerTemplate;
at net.sf.cglib.proxy.MethodProxy$1.invoke(MethodProxy.java:55)
at org.springframework.aop.framework.Cglib2AopProxy$MethodInvocationImpl.invokeJoinpoint(Cglib2AopProxy.java:884)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:596)
at com.apress.prospring.ch14.timer.Foo$$EnhancerByCGLIB$$de5c7548.createPersistenceBrokerTemplate(<generated>)
at org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport.<init>(PersistenceBrokerDaoSupport.java:63)
at com.apress.prospring.ch14.timer.Foo.<init>(Foo.java:15)
at com.apress.prospring.ch14.timer.Foo$$EnhancerByCGLIB$$de5c7548.<init>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)

This is due to a call to a protected method during object construction generating an exception in the underlying CGLIB library.


Affects: 1.1 final

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions