[SPR-328] ProxyFactoryBean does not work with prototype advisors/interceptors Created: 11/Sep/04  Updated: 15/Jan/19  Resolved: 20/Sep/04

Status: Closed
Project: Spring Framework
Component/s: Core:AOP
Affects Version/s: 1.1.1
Fix Version/s: 1.1.1

Type: Bug Priority: Major
Reporter: Chris Eldredge Assignee: Rod Johnson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File ProxyFactoryBean.patch     Text File ProxyFactoryBean.patch    
Days since last comment: 22 weeks, 1 day ago
Last commented by a User: true
Last updater: Spring Issuemaster


There are several issues in the ProxyFactoryBean which prevent it from correctly creating beans with prototype advisors:

-Cannot create proxy when using prototype advisor when singleton=false
-Cannot create proxy when using prototype interceptor when singletone=false
-Cannot create proxy when using singleton target and singleton=false (ie, to use a prototype advisor on a singleton target)

Essentially, at the moment the only part of a prototype ProxyFactoryBean which may be a prototype is the target bean.

When trying to use a prototype the following exception is thrown:

BeanCreationException: Error creating bean with name 'prototypeTestBeanProxySingletonTarget' defined in class path resource [proxyFactoryTests.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: TargetSource specified more than once: Specify in targetSource property or at the END of the interceptorNames list

Note that in targetSource is not actually specified more than once.

The main defect is that when the factory is initialized, it avoids loading prototype beans which appear in the interceptorNames property in order to improve performance. Instead it substitutes a null value. When this null value is later examined, it cannot be determined whether the bean was supposed to be a target or an advisor.

Comment by Chris Eldredge [ 11/Sep/04 ]

patch against build 96 which resolves all issues.

Comment by Chris Eldredge [ 12/Sep/04 ]

Updated patch generated on 13 Sept 2004. For some reason, previous patch does not apply cleanly.

Comment by Spring Issuemaster [ 14/Jan/19 ]

The Spring Framework has migrated to GitHub Issues. This issue corresponds to spring-projects/spring-framework#5058.

Generated at Wed Jun 19 02:50:37 UTC 2019 using JIRA 7.9.2#79002-sha1:3bb15b68ecd99a30eb364c4c1a393359bcad6278.