We are developing a Jenkins plugin that communicate with Stash and also depends on the Jenkins git plugin.
When navigating to one of the page exposed by our plugin, I have the following stacktrace:
java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.http.conn.ssl.SSLContextBuilder.loadTrustMaterial(Ljava/security/KeyStore;Lorg/apache/http/conn/ssl/TrustStrategy;)Lorg/apache/http/conn/ssl/SSLContextBuilder;" the class loader (instance of hudson/ClassicPluginStrategy$AntClassLoader2) of the current class, org/jenkinsci/plugins/hjs/git/stash/StashHttpClient, and the class loader (instance of hudson/ClassicPluginStrategy$AntClassLoader2) for the method's defining class, org/apache/http/conn/ssl/SSLContextBuilder, have different Class objects for the type org/apache/http/conn/ssl/TrustStrategy used in the signature
at org.jenkinsci.plugins.hjs.git.stash.StashHttpClient.getSslConnectionSocketFactory(StashHttpClient.java:104)
at org.jenkinsci.plugins.hjs.git.stash.StashHttpClient.getBranches(StashHttpClient.java:78)
at org.jenkinsci.plugins.hjs.git.stash.StashHttpClient.getBranches(StashHttpClient.java:73)
at org.jenkinsci.plugins.hjs.sync.SyncAnalyser.analyseRemoteBranches(SyncAnalyser.java:71)
at org.jenkinsci.plugins.hjs.sync.SyncAnalyser.analyze(SyncAnalyser.java:48)
at org.jenkinsci.plugins.hjs.sync.SyncReportAction.getReport(SyncReportAction.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.commons.jexl.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:258)
at org.apache.commons.jexl.parser.ASTMethod.execute(ASTMethod.java:104)
[...]
My understanding is that the Jenkins Git plugin has a dependency on Apache httpclient, and my plugin also has a dependency on httpclient. Somehow those 2 clash at some point.
I tried to mark my dependencies to httpclient as <scope>provided</scope>
and with the same version as the one provided by the Jenkins Git plugin. Still the same error.
I checked that my .hpj file does not contain the httpclient jars.
What else should I investigate ? Any good documentation on how classloader work in Jenkins ?