Skip to content

Error When Proxying PersistenceBrokerDaoSupport [SPR-357] #5087

Closed

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

Activity

  1. spring-projects-issues commented on Sep 28, 2004

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Always proxy interfaces :-) Juergen

  2. spring-projects-issues commented on Sep 28, 2004

    @spring-projects-issues
    CollaboratorAuthor

    Rob Harrop commented

    Thanks to Chris Nokleberg from CGLIB this is now fixed. I added a new test case to check for protected method proxying in case this creeps in again.

  3. added
    type: bug
    in: core
    on Jan 10, 2019
  4. added this to the 1.1.1 milestone on Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coretype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions