Skip to content

problem when proxy class using CGLIB [SPR-1211] #5913

@spring-projects-issues

Description

@spring-projects-issues

Jieba Wu opened SPR-1211 and commented

I'm trying to use Spring AOP, so far it works fine when I proxy interfaces(i.e use JDK Dynamic proxy), but once I switched to proxy classes(i.e use CGLIB), all of the instance variable of the target classes become null during runtime.

Here is part of the app config:


<bean id="debugInterceptor" class="org.springframework.aop.interceptor.DebugInterceptor"/>

<bean id="myTestController"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref local="myTestControllerTarget"/>
</property>
<property name="interceptorNames">
<list>
<value>debugInterceptor</value>
</list>
</property>
</bean>

<bean id="myTestControllerTarget" class="com.xxx.yyy">
<property name="someDelegate"><ref bean="someDelegate"/></property>
<property name="viewName">
<value>testName</value>
</property>
</bean>


when the method

protected ModelAndView handle(HttpServletRequest request,
HttpServletResponse response, Object command,
BindException errors) throws Exception

is invoked on myTestController, it calles:

someDelegate.doSth()

but because "someDelegate" is NULL, the app failed with NPE.


Affects: 1.2 final

Attachments:

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