-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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 scan fails to find bean candidates in the embedded jar file in META-INF/context.xml for embedded Tomcat application #34446
Comments
@osnsergey any insight into where |
@jhoeller , no, I didn't analyze it deeply yet... |
In Spring 6.1 Stack
on ln746: jarFile = rootDirResource = rootDirUrl = subPattern = on ln751 result is filled with all classes from the localization.jar:
Eventually in the
On ln457 the result from the doFindPathMatchingJarResources is then processed for bean candidates. In Spring 6.2 Stack
rootDirResource = rootDirUrl = subPattern = on ln811: jarFileUrl = on ln817: rootEntryPath = on ln820: entryPath = on ln822 the loop breaks and result isn't filled at all. Maybe the unconditional return on ln829 is a defect because the code below looks like in Spring 6.1 and could work... But that's just a guess... |
@osnsergey thanks for the analysis, I'll do a deep dive ASAP. As for the reproducer, is |
@jhoeller , it should show an exception from the issue description. The application itself doesn't stop. |
@osnsergey the app seems to bootstrap fine, no exception shown except a Tomcat debug log entry, and with both beans logged as present. This could be order-dependent, maybe my local setup leads to a different order of jar file introspection? No hurries though, I'm currently investigating how the entriesCache could possibly mismatch as you have shown above. We generally seem to be unable to handle multiple nested jars there, our TreeSet logic expects package entries from a single jar there (which is why it backs out early once the entries do not match anymore). I'll revise this. |
I'm about to push a revision that falls back to the regular search algorithm if no matching root entry path has been founded in the cache at all. According to some local tests, this addresses your scenario. |
@osnsergey please give the upcoming 6.2.4 snapshot a try! I hope we have sorted this out for good now. |
@jhoeller , just checked on test app, the issue looks fixed now. Thanks! |
Good to hear, thanks for the immediate turnaround! |
@jhoeller please clarify the 6.2.4 release date. |
@osnsergey it's been rescheduled to March 13th (as you can see on the right hand side column on this page). |
Description
Component Scan can't find annotated beans in the Web application if beans are located in the embedded .jar file.
Reproducer
A small sample application for the issue has been created: GitHub Repository (Java 17, Gradle).
Exception Stack Trace:
How to reproduce
Clone https://github.com/osnsergey/Spring62TestWebApp2, use README.md commands to run the sample.
Bean definitions can't be found in the following jar:
The text was updated successfully, but these errors were encountered: