-
Bug
-
Resolution: Done
-
Major
-
None
-
Platform: All, OS: All
While trying to use the Spring classes embedded into the Hudson war in a plugin,
I encountered the following exception:
hudson.util.IOException2: Failed to initialize
at hudson.ClassicPluginStrategy.load(ClassicPluginStrategy.java:224)
at hudson.PluginManager.<init>(PluginManager.java:156)
at hudson.model.Hudson.<init>(Hudson.java:542)
at hudson.WebAppMain$2.run(WebAppMain.java:191)
Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/TargetSource
at hudson.plugins.jmx.PluginImpl.start(PluginImpl.java:29)
at hudson.ClassicPluginStrategy.startPlugin(ClassicPluginStrategy.java:232)
at hudson.ClassicPluginStrategy.load(ClassicPluginStrategy.java:221)
... 3 more
Caused by: java.lang.ClassNotFoundException: org.springframework.aop.TargetSource
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 6 more
The issue is that the classes from spring-context that I am using depend on
spring-aop. The spring-aop artifact is declared as optional in the
spring-context POM file, so it is not bundled with the WAR. The spring-context
JAR is being pulled in transitively via Hudson's dependency on spring-web.
I attempted to work around this problem by adding spring-aop to the POM file for
my plugin, but still saw the NoClassDefFoundError, likely because the class
triggering the load of org.springframework.aop.TargetSource was not using my
plugin's classloader.
I was able to fix this by adding spring-aop to core/pom.xml. This caused the JAR
to be bundled into Hudson's main lib directory and allowed my plugin to load. I
would be happy with any solution that allows my plugin to load without having to
modify Hudson.