Skip to content

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

Closed
@bajibalu

Description

@bajibalu

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.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions