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

Most upvoted comments

For anyone hitting this issue with Drools, I found this config worked for me:

META-INF/spring-devtools.properties

restart.include.drools=/drools-[\\s\\S]+\.jar
restart.include.kie=/kie-[\\s\\S]+\.jar

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 the restartIncludePatterns 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 a restart.include.... regex to solve your issue.