0
votes

I get a typical error, because the spring context could not be found:

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsingXML document from class path resource  nested exception is java.io.FileNotFoundException: class path resource  cannot be opened because it does not exist

The class creating the spring context is instantiated in a "strange" way. There's a java process, creating a groovy classloader and adding the required classpath entries (including the jar with the spring context). Using this classloader a groovy script will be executed, which in turn executes a java class creating a spring bean in the static init block. Unfortunately this fails with the above exception.

If the initial java process is called with -cp jarContainingContext it works. The jar containing the spring context, also contains the java class creating the spring context. Thus I'm sure that the jar is in the classpath.

Is it possible the the groovy classloader is different from the one of spring (if there's a seperate one)?

java MyClass -> Creates groovy classloader with all required classpath entries -> runscript -> groovy script -> running java class from a library also containing the spring context -> tries to create the bean within the static initializer -> failure

This whole chain sounds quite strange, it is but I can't really change it. I simply cannot understand where the problem is. Because the java class creating the spring context will be found by the groovy classloader but not the springContext within the same jar. It seems like there are 2 seperate classpaths.

1

1 Answers

0
votes

The problem are really the classloaders. SpringBatch has a bug and might use the system classloader. Thus a classloader hell is created.

We issued a pull request to fix the issue.