Hi,
we are running Jenkins on Tomcat and need to use XPath in a custom Jenkins plugin.
In our plugin we do have the following dependency:
<dependency>
<groupId>org.sonatype.nexus.restlight</groupId>
<artifactId>nexus-restlight-stage-client</artifactId>
<version>2.0.3</version>
</dependency>
That nexus-restlight-stage-client is using Javen to evaluate XPaths.
Since Jaxen is also part of Jenkins and is loaded before our plugin but if we try to use XPath, then our plugin uses the XPath functionality provided by the Jaxen which is part of Jenkins (simply by classloader deligation).
By using the Jaxen in our Action class (called during rendering the jelly UI) we run into following Exception:
Caused by: org.sonatype.nexus.restlight.common.RESTLightClientException: Failed to build xpath: '/status/data/apiVersion/text()'.
at org.sonatype.nexus.restlight.common.AbstractRESTLightClient.getApiVersion(AbstractRESTLightClient.java:400)
at org.sonatype.nexus.restlight.common.AbstractRESTLightClient.loadVocabulary(AbstractRESTLightClient.java:295)
at org.sonatype.nexus.restlight.common.AbstractRESTLightClient.connect(AbstractRESTLightClient.java:236)
at org.sonatype.nexus.restlight.common.AbstractRESTLightClient.<init>(AbstractRESTLightClient.java:183)
at org.sonatype.nexus.restlight.stage.StageClient.<init>(StageClient.java:100)
at com.sap.ldi.releasetools.internal.stage.StageClientFactory.createStageClient(StageClientFactory.java:69)
... 129 more
Caused by: org.jdom.JDOMException: java.lang.NoClassDefFoundError: org/jdom/Parent: org/jdom/Parent
at org.jdom.xpath.XPath.newInstance(XPath.java:146)
at org.sonatype.nexus.restlight.common.AbstractRESTLightClient.getApiVersion(AbstractRESTLightClient.java:396)
... 134 more
Caused by: java.lang.NoClassDefFoundError: org/jdom/Parent
at org.jaxen.jdom.JDOMXPath.<init>(JDOMXPath.java:91)
at org.jdom.xpath.JaxenXPath.setXPath(JaxenXPath.java:281)
at org.jdom.xpath.JaxenXPath.<init>(JaxenXPath.java:99)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.jdom.xpath.XPath.newInstance(XPath.java:137)
... 135 more
Caused by: java.lang.ClassNotFoundException: org.jdom.Parent
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
... 143 more
We managed to workaround that Exception by putting a jdom.jar into the WEB-INF/lib folder of Jenkins. But this is of course an ugly Workaround and hinders Jenkins updates in future.
And we noticed that this issue is not occuring when using Jaxen on Jetty.
Also we had a look into the Jenkins sources and found out that the core/pom.xml contains an explicite exclusion of jdom.
By deleting those exclusions the Jenkins.war containes the jdom.jar. But saddly we are not able to run the Jenkins test suite (even for unchanges sources) and can't verify wether such a change breaks other Jenkins functionality.
How ever a fix is realized, as long as Jenkins is delivering Jaxen, it should be delivered with all features of Jaxen and that is also XPath.
You can find our pom.xml changes as patch appended to this Issue.
Thx for any help
Regards Matthias
|