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

BeanNotOfRequiredTypeException during transaction qualifier resolution in 6.2.1 #34187

Closed
zesman21 opened this issue Jan 2, 2025 · 4 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression
Milestone

Comments

@zesman21
Copy link

zesman21 commented Jan 2, 2025

Hi,

i am getting this exception from spring after upgrading versions from 6.1.14 to 6.2.1

Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'CTIChild' is expected to be of type 'org.springframework.transaction.TransactionManager' but was actually of type 'org.springbug.txbug.CTIChild$$SpringCGLIB$$0'

i created an example project where the issue can be reproduced.

https://github.com/zesman21/springbug/tree/main

This commit intruduced this spring framework issue:
#24291

can you please have a look at that issue and confirm that this is a real bug?

thanks

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 2, 2025
@quaff
Copy link
Contributor

quaff commented Jan 3, 2025

You can fix it by using @Component("CTIChild") instead of @Component @Qualifier("CTIChild"), please refer to Javadoc of Qualifier.

This annotation may be used on a field or parameter as a qualifier for candidate beans when autowiring. It may also be used to annotate other custom annotations that can then in turn be used as qualifiers.

@zesman21
Copy link
Author

zesman21 commented Jan 3, 2025

thx for the info

@quaff
Copy link
Contributor

quaff commented Jan 3, 2025

I think it's a regression, fixed by #34191.

quaff added a commit to quaff/spring-framework that referenced this issue Jan 3, 2025
@jhoeller
Copy link
Contributor

The underlying bug is actually in the BeanFactoryAnnotationUtils.qualifiedBeanOfType implementation where the fallback to a bean name should defensively check whether it matches the expected type first, never resulting in a BeanNotOfRequiredTypeException. To be fixed for 6.2.2.

@jhoeller jhoeller added in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 13, 2025
@jhoeller jhoeller self-assigned this Jan 13, 2025
@jhoeller jhoeller added this to the 6.2.2 milestone Jan 13, 2025
@jhoeller jhoeller changed the title BeanNotOfRequiredTypeException after upgrading from version: 6.1.14 to 6.2.1 BeanNotOfRequiredTypeException during transaction qualifier resolution in 6.2.1 Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression
Projects
None yet
4 participants