Details
Description
I am converting a Spring XD Sample (Batch notifications) from copying jars to (old way)
$XD_HOME/lib
To rather copy the module jar to (new preferred way)
$XD_HOME/modules/job/payment-import/lib
By doing so, I hit a classloader issue. Custom classes and resources are loaded in Spring XD using org.springframework.xd.module.support.ParentLastURLClassLoader.
However, the sample is initializing custom bean definitions and one of those creates a new DataSource using the EmbeddedDatabaseBuilder. This class however, under the hood, uses the Default class loader to load SQL scripts:
public DefaultResourceLoader() { this.classLoader = ClassUtils.getDefaultClassLoader(); }
Therefore, the SQL scripts are NOT FOUND.
Possible Solution
A possible solution seems to be for ParentLastURLClassLoader to set itself as the context ClassLoader for the current thread:
public ParentLastURLClassLoader(URL[] classpath, ClassLoader parent) { ... Thread.currentThread().setContextClassLoader(this); ... }