Java 自定义Jenkins插件中的类加载器问题

Java 自定义Jenkins插件中的类加载器问题,java,maven,plugins,jenkins,classloader,Java,Maven,Plugins,Jenkins,Classloader,我们正在开发一个插件,该插件可以与服务器进行通信,也依赖于服务器 当导航到我们的插件公开的某个页面时,我有以下stacktrace: java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.http.conn.ssl.SSLContextBuilder.loadTrustMaterial(Ljava/security/KeyStore;Lorg/apache/http/conn/

我们正在开发一个插件,该插件可以与服务器进行通信,也依赖于服务器

当导航到我们的插件公开的某个页面时,我有以下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)
[...]
我的理解是Jenkins Git插件依赖于,我的插件也依赖于httpclient。不知怎的,这两个在某个点上发生了冲突

我试图将我对httpclient的依赖项标记为
提供的
,并且与Jenkins Git插件提供的版本相同。还是一样的错误

我检查了我的.hpj文件是否不包含httpclient JAR


我还应该调查什么?任何关于类加载器在Jenkins中如何工作的好文档?

都遇到了几乎相同的问题(很多年了)-我需要使用的apache http客户端版本与maven插件中引用的超旧版本之间存在冲突。您可能会发现,在您的例子中,有更多的插件引用http客户端,因此您的插件与git插件以外的其他插件发生冲突。我与直接尝试告诉类加载器(在代码中)要选择哪个版本的库进行了斗争,但没有运气。我最终切换到了做所有相同事情的软件包(事实上,在引擎盖下使用了apache http客户端,但是“着色”重命名了包,所以没有冲突)。。。现在工作得很好(性能略有提高)