Description
Hi there,
We have a situation where we have a multi module Gradle project that has shared Spring components, but hot restart fails due to classloader issues. This is with Spring Boot 1.5.1.RELEASE.
FYI I've put together an example of the error we're having here
Within our project we have some shared @Services
that are used by several web applications. These shared services live in their own module within the main project structure and have a bunch of @Service
classes within it.
A web application will be in a separate module within the main project structure and will have a "compile project" dependency on the shared services module. It then has @Controller
controllers that use the @Service
services from the dependency. The web application is build with bootRepackage
and run as a standalone jar, with the shared services module as a jar within BOOT-INF/lib
.
The problem occurs when updating anything in the shared services module that causes a hot reload. If that happens, the remote hot reload process (using RemoteSpringApplication
) tells the RestartServer
to do a reload of the classes only within the shared services jar. The newly reloaded @Services
are now available in the RestartClassLoader
. When Spring fires up to do the hot restart process, it is unable to wire up the @Controllers
with the @Services
, because the @Controllers
are in the LauchedURLClassLoader
but the @Services
are now in the RestartClassLoader
, and so when it's trying to wire up a controller with a particular @Service
class it is unable to find it because it's no longer in the same classloader as the @Controller
.
It seems like it would be good if there was some flag to say to restart everything that can be reloadable at the same time, so that you don't end up having some potentially reloadable stuff in one loader and other potentially reloadable stuff in the the loader.
Many thanks for your time and help,
Duncan