0

我正在尝试集成 scribe-java 并为其编写一个 Jenkins 插件,但似乎 Jenkins 不能与 Class 一起使用?有谁知道这是为什么?

詹金斯插件代码:

    OAuthService service =
            new ServiceBuilder().provider( com.lookout.jenkins.publishoverbox.BoxApi20.class ).apiKey( clientId ).apiSecret(clientSecret ).callback(callbackUrl).grantType( OAuthConstants.AUTHORIZATION_CODE ).build();

日志:

SEVERE: Failed to create Guice container from all the plugins
com.google.common.collect.ComputationException: java.lang.NoClassDefFoundError: Lorg/scribe/oauth/OAuthService;
    at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:397)
    at com.google.inject.internal.FailableCache.get(FailableCache.java:49)
    at com.google.inject.internal.MembersInjectorStore.get(MembersInjectorStore.java:66)
    at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:73)
    at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
    at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:36)
    at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
    at com.google.inject.internal.FailableCache$1.apply(FailableCache.java:38)
    at com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:355)
    at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
    at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
    at com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
    at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:393)
    at com.google.inject.internal.FailableCache.get(FailableCache.java:49)
    at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49)
    at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:127)
    at com.google.inject.internal.InjectorImpl.initializeBinding(InjectorImpl.java:506)
    at com.google.inject.internal.AbstractBindingProcessor$Processor$1.run(AbstractBindingProcessor.java:171)
    at com.google.inject.internal.ProcessedBindingData.initializeBindings(ProcessedBindingData.java:44)
    at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:123)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
    at com.google.inject.Guice.createInjector(Guice.java:94)
    at com.google.inject.Guice.createInjector(Guice.java:71)
    at hudson.ExtensionFinder$GuiceFinder.<init>(ExtensionFinder.java:282)
    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 java.lang.Class.newInstance0(Class.java:357)
    at java.lang.Class.newInstance(Class.java:310)
    at net.java.sezpoz.IndexItem.instance(IndexItem.java:181)
    at hudson.ExtensionFinder$Sezpoz._find(ExtensionFinder.java:625)
    at hudson.ExtensionFinder$Sezpoz.find(ExtensionFinder.java:600)
    at hudson.ExtensionFinder._find(ExtensionFinder.java:151)
    at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:318)
    at hudson.ExtensionList.load(ExtensionList.java:295)
    at hudson.ExtensionList.ensureLoaded(ExtensionList.java:248)
    at hudson.ExtensionList.iterator(ExtensionList.java:138)
    at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:311)
    at hudson.ExtensionList.load(ExtensionList.java:295)
    at hudson.ExtensionList.ensureLoaded(ExtensionList.java:248)
    at hudson.ExtensionList.get(ExtensionList.java:153)
    at hudson.PluginManager$PluginUpdateMonitor.getInstance(PluginManager.java:1066)
    at hudson.maven.PluginImpl.init(PluginImpl.java:54)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at hudson.init.InitializerFinder.invoke(InitializerFinder.java:120)
    at hudson.init.InitializerFinder$TaskImpl.run(InitializerFinder.java:184)
    at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
    at jenkins.model.Jenkins$7.runTask(Jenkins.java:888)
    at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
    at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NoClassDefFoundError: Lorg/scribe/oauth/OAuthService;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2300)
    at java.lang.Class.getDeclaredFields(Class.java:1745)
    at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:651)
    at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:358)
    at com.google.inject.internal.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:91)
    at com.google.inject.internal.MembersInjectorStore.access$000(MembersInjectorStore.java:35)
    at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:43)
    at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:40)
    at com.google.inject.internal.FailableCache$1.apply(FailableCache.java:38)
    at com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:355)
    at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
    at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
    at com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
    at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:393)
    ... 56 more
Caused by: java.lang.ClassNotFoundException: org.scribe.oauth.OAuthService
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 71 more
Jun 3, 2013 11:37:17 AM jenkins.InitReactorRunner$1 onAttained
4

1 回答 1

0

无论您在插件中需要什么,都可以在依赖项中指定相同的内容。

原因一:

Jenkins 将每个插件加载到单独的类加载器中以避免冲突。然后插件可以像其他 Jenkins 内置类一样参与系统活动。他们可以参与基于 XStream 的持久性,他们可以通过 Jelly 提供“视图”,他们可以提供像图像这样的静态资源,并且从用户那里,一切都可以无缝运行——内置功能与插件功能之间没有区别.

原因 2:当 jenkins 更改其依赖项时,您不想更改代码。

于 2013-06-04T15:04:02.147 回答