Skip to content

ConfigDataResourceNotFoundException incorrectly thrown for valid classpath locations #24143

@bratkartoffel

Description

@bratkartoffel

Hi,

after upgrading from spring boot 2.3.6 to 2.4.0 our application fails to startup. We tracked the error to our startup options, we use the following to setup the configuration resources paths:
--spring.config.location=classpath:/,file:../etc/

This results in the following error message:

***************************
APPLICATION FAILED TO START
***************************

Description:

Config data resource 'class path resource []' via location 'classpath:/' does not exist

Action:

Check that the value 'classpath:/' is correct, or prefix it with 'optional:'

07:53:54.024 [main] ERROR com.xxx.server.launcher.XxxServerApplication - Error starting up / running context
org.springframework.boot.context.config.ConfigDataResourceNotFoundException: Config data resource 'class path resource []' via location 'classpath:/' cannot be found
        at org.springframework.boot.context.config.ConfigDataResourceNotFoundException.withLocation(ConfigDataResourceNotFoundException.java:97)
        at org.springframework.boot.context.config.ConfigDataImporter.handle(ConfigDataImporter.java:133)
        at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:104)
        at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:93)
        at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:81)
        at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:118)
        at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:230)
        at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:217)
        at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:88)
        at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:80)
        at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:100)
        at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:86)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:203)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:196)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:170)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:148)
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
        at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
        at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
        at com.xxx.xxx.server.launcher.XxxServerApplication.main(XxxServerApplication.java:49)

The same setting works fine on the previous spring boot version.
We need this setting as we ship some default profiles within our jar, but also allow the user to use custom profiles within the "etc" folder.
Prefixing the "classpath:" with "optional:" doesn't print any error, but then the embedded profiles are not found.

Thanks,
Simon

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions