Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Injecting prototypes into tests using @Resource appears to be broken [SPR-9580] #14214
When injecting a prototype bean into a test derived from AbstractJUnit4SpringContextTests using
As a workaround, I now use
The attached project uses a unit test to show the problem. Changing the Spring version to 3.1.1-RELEASE (or lower) in the pom fixes the issue.
5 votes, 6 watchers
Juan Osuna commented
I am getting the same issue with previously working non-test-related production code. Upgrade from 3.1.1 to 3.1.2 seems to be causing several problems with session and prototype scopes.
I have an bean object tree with the root being session scope. The rest of the tree consists of prototype beans. The same prototype instance is being injected into different beans in the object tree rather than a new one being created for each
Michał Rembiszewski commented
Having a very similar behavior:
I have a session scoped bean A injected into another session scoped bean B with