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

Component scanning no longer uses component index for @Named, @ManagedBean, and other Jakarta annotations #29641

Closed
aurifolia opened this issue Dec 5, 2022 · 4 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Milestone

Comments

@aurifolia
Copy link

aurifolia commented Dec 5, 2022

ClassPathScanningCandidateComponentProvider#indexSupportsIncludeFilter attempts to match jakarta.annotation.ManagedBean, but the match fails.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 5, 2022
@mhalbritter
Copy link
Contributor

Hello! I don't understand. What exactly did you do, what is expected and what happened?

@mhalbritter mhalbritter added the status: waiting-for-feedback We need additional information before we can continue label Dec 5, 2022
@aurifolia
Copy link
Author

I generated an empty spring boot 3.0.0 project with "start.spring.io" and then added a "spring-context-indexer" dependency through gradle, like this annotationProcessor 'org.springframework:spring-context-indexer'. And then I add @Indexed on the startup class. The project does generate the META-INF/spring.components file after compiling, but I find that the spring.components file is not used when the project is started.
I changed the springboot version to 2.7.6 and found that the spring.components file was used when the project started.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 6, 2022
@aurifolia
Copy link
Author

I break points found org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider#findCandidateComponents(String basePackage) this method called indexSupportsIncludeFilters(), and indexSupportsIncludeFilters() returns false. But under the 2.7.6 version indexSupportsIncludeFilters() returns true.
So scanning the classpath for candidate components under 2.7.6 uses the spring.components file, but not under 3.0.0

@bclozel bclozel transferred this issue from spring-projects/spring-boot Dec 6, 2022
@bclozel bclozel changed the title springboot 3.0.0 references the spring-context-indexer package, and by default @Indexed does not work. Spring Framework 6.0 does not use components index built at compile time Dec 6, 2022
@sbrannen sbrannen added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Dec 6, 2022
@sbrannen sbrannen self-assigned this Dec 6, 2022
@sbrannen sbrannen added this to the 6.0.3 milestone Dec 6, 2022
@sbrannen
Copy link
Member

sbrannen commented Dec 6, 2022

StandardStereotypesProvider was updated to support Jakarta annotations (such as @jakarta.annotation.ManagedBean) in d84ca2b#diff-2bdfddc22d2d1845f4ed7b6705fe73ba79a638f1d739909ab49099cd36a62e0c in conjunction with #25354, but ClassPathScanningCandidateComponentProvider#indexSupportsIncludeFilter was not updated accordingly and still matches against annotations whose fully qualified names start with "javax."

@sbrannen sbrannen changed the title Spring Framework 6.0 does not use components index built at compile time Component scanning no longer uses component index for @Named, @ManagedBean, and other Jakarta annotations Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants