spring-boot: Devtools: Same class with different classloader causing NoSuchBeanDefinitionException
@philwebb I have started to check our applications and came across an issue. (Sorry if It is already fixed)
Short description: My applications can not find some of beans when application starts.
Detailed description: I have debugged and found that If a class is loaded with two different class loader, the java.lang.Class#isAssignableFrom
seems can not handle correctly. This is causing a problem in org.springframework.util.ClassUtils#isAssignable
which is used for bean comparison. As a result a bean not found exception is raised.
I have checked each class and noticed that classes are loaded by AppClassLoader
and RestartClassLoader
.
This bean is registered by @Import
configuration class. Spring Framework is registering beans with AppClassLoader
but classes of other beans are loaded by RestartClassLoader
.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 32 (25 by maintainers)
Commits related to this issue
- Add support for `spring-devtools.properties` Allow `META-INF/spring-devtools.properties` files to be used by application developers to declare is specific jars should be included or excluded from the... — committed to spring-projects/spring-boot by philwebb 9 years ago
- moved remoting magic into separate project added spring-boot-autoremote added jitpack repository for grabbing spring-boot-autoremote dependencies added MIT license added spring boot devtools workaroun... — committed to martinfoersterling/spring-boot by martinfoersterling 7 years ago
For anyone hitting this issue with Drools, I found this config worked for me:
META-INF/spring-devtools.properties
It will happen indeed with any library that deserialize content. Caching libraries, in particular, are affected.
@gaeloberson That should be the right place. Try putting a breakpoint on
DevToolsSettings.isRestartInclude(...)
to see if therestartIncludePatterns
get loaded and if the regex applies cleanly. If you don’t get anywhere please open a new issue (ideal with a sample project to reproduce the problem).I’ve added support for
META-INF/spring-devtools.properties
files which can be used to pull jars up to the restart classloader. Hopefully you can add arestart.include....
regex to solve your issue.