Similar to the issue raised in https://github.com/spring-projects/spring-boot/issues/26126, when using Spring Boot 2.5.0 org.springframework.boot.env.ReflectionEnvironmentPostProcessorsFactory
will not use the class loader from the SpringApplication's ResourceLoader
when instantiating EnvironmentPostProcessors
.
It appears to me the classloader would need to be passed to the instantiator here https://github.com/spring-projects/spring-boot/blob/07c9418b85da40d1b981314100629d98326c516b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ReflectionEnvironmentPostProcessorsFactory.java#L63. That way https://github.com/spring-projects/spring-boot/blob/07c9418b85da40d1b981314100629d98326c516b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/Instantiator.java#L98 could use the correct classloader rather than being passed "null". ReflectionEnvironmentPostProcessorsFactory would need to be made aware of the SpringApplication's ClassLoader as well.
Comment From: philwebb
There are two parts to this bug. The first is that we're not passing a classloader to the Instantiator
, the second is that we want to use ResourceLoader.getClassloader()
.
I'll use this issue to fix the first problem in 2.4.x. The second part we'll fix in 2.5.x under #27071