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

时间:2015-02-04 10:24:01

标签: java maven plugins jenkins classloader

我们正在开发一个与Jenkins进行通信的Stash插件,并且还取决于Jenkins git plugin

导航到我们的插件公开的页面之一时,我有以下堆栈跟踪:

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插件依赖Apache httpclient,我的插件也依赖于httpclient。不知何故,这两个人在某些时候发生冲突。

我尝试将我的依赖项标记为http <scope>provided</scope>,并使用与Jenkins Git插件提供的版本相同的版本。仍然是同样的错误。

我检查过我的.hpj文件不包含httpclient jar。

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

0 个答案:

没有答案