Project: springxd
Issue XD-1994: ParentLastURLClassLoader should set itself as context ClassLoader
I am converting a Spring XD Sample (Batch notifications) from copying jars to (old way) {code} $XD_HOME/lib {code} To rather copy the module jar to (new preferred way) {code} $XD_HOME/modules/job/payment-import/lib {code} 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: {code}	public DefaultResourceLoader() {	this.classLoader = ClassUtils.getDefaultClassLoader();	} {code} 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: {code}	public ParentLastURLClassLoader(URL[] classpath, ClassLoader parent) {	...	Thread.currentThread().setContextClassLoader(this);	...	} {code}
Story points: 4