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

FileNotFoundException is thrown when using ConfigurationPropertiesScan with Spring Context 6.2.1 #34216

Closed
bajibalu opened this issue Jan 9, 2025 · 7 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

@bajibalu
Copy link

bajibalu commented Jan 9, 2025

Spring Boot version: 3.4.1
Spring Core version: 6.2.1

I am getting FileNotFoundException: JAR entry my/app/config/ not found in my-app.jar!/BOOT-INF/lib/dependency.jar
when using @ComponentScan and @ConfigurationPropertiesScan annotations and having a dependency.jar that contains common parent package that matches ConfigurationPropertiesScan.basePackages value.

This exception is thrown when PathMatchingResourcePatternResolver takes resources from rootDirCache that match common parent directory, updates the resource path and tries to access a directory that does not exist in that jar file.

I have a dependency.jar in my application that contains my.app package and the Application class configured like below.

@SpringBootApplication
@ConfigurationPropertiesScan("my.app.config")
@ComponentScan(basePackages = ["my.app"])
class Application
fun main(args: Array<String>) {
    @Suppress("SpreadOperator")
    runApplication<Application>(*args)
}

In this case,

  • An entry with my.app as key and dependency.jar!/my/app as value is added to rootDirCache while processing the @componentscan annotation
  • The same entry is read while processing ConfigurationPropertiesScan annotation as patent package matches
  • The File not found exception is thrown when it tries to access dependency.jar!/my/app/config which does not present in that jar file.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 9, 2025
@snicoll
Copy link
Member

snicoll commented Jan 9, 2025

Duplicate of #34111

@bajibalu if you want to make sure your use case is tested as you experience it, you can attach a sample to that issue. Not code in text, but something we can actually run.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2025
@snicoll snicoll added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 9, 2025
@bajibalu

This comment was marked as resolved.

@snicoll

This comment was marked as resolved.

@jhoeller
Copy link
Contributor

This turned out to be related but not quite a duplicate, so I'll individually schedule this for 6.2.2 (also for potential follow-ups).

@jhoeller jhoeller reopened this Jan 12, 2025
@jhoeller jhoeller added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) and removed status: duplicate A duplicate of another issue labels Jan 12, 2025
@jhoeller jhoeller self-assigned this Jan 12, 2025
@jhoeller jhoeller added this to the 6.2.2 milestone Jan 12, 2025
@jhoeller
Copy link
Contributor

jhoeller commented Jan 13, 2025

@bajibalu this is available in the latest 6.2.2 snapshot now, please give it an early try if you have the chance (before 6.2.2 becomes generally available on Thursday).

@bajibalu
Copy link
Author

@jhoeller and @snicoll I tested the fix with spring-core 6.2.2-SNAPSHOT. I no longer see the FileNotFoundException. The app started successfully. Thank you.

@jhoeller
Copy link
Contributor

Good to hear! Thanks for the immediate feedback, @bajibalu.

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