-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Description
After upgrading Spring Boot from version 2.7.18 to 3.4.5, I was using CompletableFuture.runAsync to execute scheduled tasks. However, after the upgrade, these scheduled tasks could no longer be executed and would throw a ClassNotFoundException, specifically in the ResourceLoaderClassLoadHelper#loadClass(String name)method.
Interestingly, this problem didn't occur when I started the project locally through IDEA - it only appeared when starting the application from the packaged JAR (which worked fine before the upgrade).
Ultimately, I resolved the issue by manually specifying an Executor for CompletableFuture. However, I'm still unclear about the exact underlying mechanism that caused this behavior.
Additional Technical Context:
This issue likely relates to Spring Boot 3.x's enhanced module system and class loading isolation, where asynchronous tasks might lose thread context class loader visibility when no explicit executor is provided. The manual executor specification probably preserves the correct class loader context.
I provided a demo project to reproduce this error. The project uses MySQL database and can initialize data using demo.sql. After the project is packaged in a jar file, run it using Java jar and call the/app/jobs/create interface, and ClassNotFoundException will be found。
see demo project: https://github.com/NoahArno/quartz_async_error_demo
the exception capture is:
