-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
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:
- cglib_test.zip (2.30 kB)
- screenshot-Non-Controller.jpg (70.88 kB)