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

Custom ConfigDataLocationResolver/ConfigDataLoader fails in 3.0.x when combined with spring-boot-devtools #34372

Closed
sestrel opened this issue Feb 24, 2023 · 2 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@sestrel
Copy link

sestrel commented Feb 24, 2023

Using ConfigDataLocationResolver/ConfigDataLoader in 3.0.2 in combination with spring-boot-devtools leads to the following error on application start:

> Task :bootRun
09:11:43.399 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: No loader found for resource 'com.example.demo.DemoDataResource@30afc98d'
        at org.springframework.util.Assert.state(Assert.java:97)
        at org.springframework.boot.context.config.ConfigDataLoaders.getLoader(ConfigDataLoaders.java:115)
        at org.springframework.boot.context.config.ConfigDataLoaders.load(ConfigDataLoaders.java:94)
        at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:128)
        at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:86)
        at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:115)
        at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:242)
        at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:229)
        at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:96)
        at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:89)
        at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:109)
        at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:94)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
        at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
        at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
        at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:354)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293)
        at com.example.demo.DemoApplication.main(DemoApplication.java:10)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)

I've create sample applications for spring boot 2.7.8 and 3.0.2. Spring boot 2.7.8 works, 3.0.2 fails to start. Please run the command gradlew clean bootRun in each directory. Here is the link to my sample git repository: https://github.com/sestrel/ConfigDataLocationResolver

The comparison in line https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataLoaders.java#L104 seems to fail because type and instance have different ClassLoaders in 3.0.2.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 24, 2023
@sbrannen
Copy link
Member

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

@sbrannen sbrannen added the for: external-project For an external project and not something we can fix label Feb 24, 2023
@bclozel bclozel removed the for: external-project For an external project and not something we can fix label Feb 24, 2023
@bclozel bclozel transferred this issue from spring-projects/spring-framework Feb 24, 2023
@wilkinsona wilkinsona removed the status: waiting-for-triage An issue we've not yet triaged label Feb 24, 2023
@wilkinsona wilkinsona added this to the 3.0.x milestone Feb 24, 2023
@wilkinsona wilkinsona added the type: regression A regression from a previous release label Feb 24, 2023
@wilkinsona
Copy link
Member

This is a regression introduced in 770cb84. We're no longer passing in the resource loader's class loader when loading the config data loaders.

@wilkinsona wilkinsona self-assigned this Feb 24, 2023
@wilkinsona wilkinsona changed the title Using ConfigDataLocationResolver/ConfigDataLoader fails in 3.0.2 when combined with spring-boot-devtools Custom ConfigDataLocationResolver/ConfigDataLoader fails in 3.0.x when combined with spring-boot-devtools Feb 24, 2023
@wilkinsona wilkinsona modified the milestones: 3.0.x, 3.0.4 Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

5 participants