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:
Referenced from: commits ac5933a, 7ac9f92
Marten Deinum opened SPR-14921 and commented
When using a
GenericApplicationContextFactoryit, by default, use theConfigurableBeanFactory.copyConfigurationFrommethod. This method also copies theAutowireCandidateResolverfrom the parent, which internally references aBeanFactorywhich effectively points to the parent instead of the currentBeanFactory.This introduces an issue when trying to resolve generic typed dependencies, which is an issue in the
isAutowireCandidatein deDefaultListableBeanFactorywhich ultimately delegates to the configuredAutowireCandidateResolver. 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
GenericApplicationContextFactoryand reset theAutowireCandidateResolveron 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.copyConfigurationFromis actually copying theautowireCandidateResolver.Affects: 4.3.4
Issue Links:
Referenced from: commits ac5933a, 7ac9f92