Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeanDefinitions registered using BeanDefinitionRegistry not always eligible for autowiring when using @Qualifier [SPR-10736] #15364

Closed
spring-issuemaster opened this issue Jul 11, 2013 · 3 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jul 11, 2013

Allard Buijze opened SPR-10736 and commented

I use a custom namespace, and have some BeanDefinitionParsers that generate bean definitions. In one case, I need a single xml element to produce multiple bean definitions. It seems to work just fine by registering the non-primary beans using the parerContext->beanDefinitionRegistry.

However, when a bean has a dependency on one of these non-primary beans using the bean id as value in @Qualifier, the bean is not found. If I use ApplicationContext.getBean, I can find it. Strangely, if I use the @Autowired and @Qualifier in a junit unit test(with SpringJunit4Runner), they are properly injected.

This worked in Spring 3.1.x, but doesn't in 3.2.x. I've doublechecked the documentation to ensure that I didn't do something that made it work 'accidentally' in 3.1. Couldn't find anything.

  • Update --
    Further investigation revealed that the fact that I am using a BeanDefinition using "factoryBeanName" and "factoryMethodName" has to do with the error. When using a FactoryBean instead, the problem is circumvented. This may mean it has nothing to do with (non-)primary beans, but more with the dependency resolution and the factoryMethod way of defining beans.

Affects: 3.2 GA, 3.2.1, 3.2.2, 3.2.3

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 25, 2014

Juergen Hoeller commented

I'm wondering whether this still a problem against 3.2.11 or recent 4.x releases? Qualifiers should work with any kind of bean definition, after all...

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 28, 2014

Allard Buijze commented

I can reproduce it in 3.2.4, but in 3.2.5 and later (including 3.2.11), the problem is fixed. I can't reproduce it in 4.x either.
Seems like the problem is solved.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 28, 2014

Juergen Hoeller commented

Alright, thanks for re-testing this!

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.