Description
Marten Deinum opened SPR-14921 and commented
When using a GenericApplicationContextFactory
it, by default, use the ConfigurableBeanFactory.copyConfigurationFrom
method. This method also copies the AutowireCandidateResolver
from the parent, which internally references a BeanFactory
which effectively points to the parent instead of the current BeanFactory
.
This introduces an issue when trying to resolve generic typed dependencies, which is an issue in the isAutowireCandidate
in de DefaultListableBeanFactory
which ultimately delegates to the configured AutowireCandidateResolver
. This now tries to resolve/check the dependency with the parent instead of the current context.
To solve this for now we have a extended the GenericApplicationContextFactory
and reset the AutowireCandidateResolver
on the context created. This solves the issue of not being able to auto wire beans.
This could be a bug/issue in Spring itself instead of Spring Batch as the DefaultListableBeanFactory.copyConfigurationFrom
is actually copying the autowireCandidateResolver
.
Affects: 4.3.4
Issue Links:
- getBeanDefinitionNames should not leak the frozenBeanDefinitionNames array [SPR-14897] #19463 getBeanDefinitionNames should not leak the frozenBeanDefinitionNames array