NoClassDefFoundError: com/cloudbees/plugins/credentials/CredentialsProvider

2,347 views
Skip to first unread message

Jacqueline Taing

unread,
Sep 30, 2015, 6:11:51 PM9/30/15
to Jenkins Developers
Hi all,

I'm getting the following error during the injected test when I build my plugin:

Sep 30, 2015 3:02:41 PM hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1 error
WARNING: Failed to instantiate Key[type=com.cloudbees.hudson.plugins.folder.properties.FolderCredentialsProvider$FolderCredentialsProperty$DescriptorImpl, annotation=[none]]; skipping this component
com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: com/cloudbees/plugins/credentials/CredentialsProvider
  at com.cloudbees.hudson.plugins.folder.properties.FolderCredentialsProvider$FolderCredentialsProperty$DescriptorImpl.<init>(Unknown Source)

1 error
        at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:52)
        at com.google.inject.Scopes$1$1.get(Scopes.java:59)
        at hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1.get(ExtensionFinder.java:429)
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
        at com.google.inject.internal.InjectorImpl$3$1.call(InjectorImpl.java:965)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011)
        at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:961)
        at hudson.ExtensionFinder$GuiceFinder._find(ExtensionFinder.java:391)
        at hudson.ExtensionFinder$GuiceFinder.find(ExtensionFinder.java:382)
        at hudson.ExtensionFinder._find(ExtensionFinder.java:151)
        at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:316)
        at hudson.ExtensionList.load(ExtensionList.java:295)
        at hudson.ExtensionList.ensureLoaded(ExtensionList.java:248)
        at hudson.ExtensionList.getComponents(ExtensionList.java:149)
        at hudson.DescriptorExtensionList.load(DescriptorExtensionList.java:182)
        at hudson.ExtensionList.ensureLoaded(ExtensionList.java:248)
        at hudson.ExtensionList.size(ExtensionList.java:157)
        at java.util.AbstractCollection.isEmpty(AbstractCollection.java:86)
...
Caused by: java.lang.NoClassDefFoundError: com/cloudbees/plugins/credentials/CredentialsProvider
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
...
Caused by: java.lang.ClassNotFoundException: com.cloudbees.plugins.credentials.CredentialsProvider
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 60 more

My pom.xml has the following:

  <parent>
    <groupId>org.jenkins-ci.plugins</groupId>
    <artifactId>plugin</artifactId>
    <version>>1.554.1</version><!-- which version of Jenkins is this plugin built against? -->
  </parent>

        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>cloudbees-folder</artifactId>
            <version>4.10</version>
            <type>jar</type>
        </dependency>

Any ideas?

Thanks,
-jacqui

Victor Martinez

unread,
Sep 30, 2015, 6:18:56 PM9/30/15
to Jenkins Developers
Some missing dependencies:

You might need to add it as part of your pom.xml file, scope test:


I hope it helps

Jesse Glick

unread,
Sep 30, 2015, 6:42:30 PM9/30/15
to Jenkins Dev
On Wed, Sep 30, 2015 at 6:18 PM, Victor Martinez
<victormar...@gmail.com> wrote:
> Some missing dependencies:
> - https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Plugin

Specifically `cloudbees-folder` has

https://github.com/jenkinsci/cloudbees-folder-plugin/blob/cloudbees-folder-4.10/pom.xml#L55-L60

Since this is an `optional` dependency, it does not automatically get
included transitively in your plugin’s test classpath. If you want it,
you need to add it.

That said, it looks like a bug in `cloudbees-folder` that it has this
optional dependency yet does not behave gracefully when the dependency
is missing. Possibly it suffices for `@Extension` to be marked
`(optional=true)`. Perhaps file a bug/PR.

Jacqueline Taing

unread,
Oct 1, 2015, 1:55:22 PM10/1/15
to Jenkins Developers
Thanks all! I did have to add the dependencies to pom.xml.  I added the two items below and now everything is good.

        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>credentials</artifactId>
            <version>1.8.3</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>matrix-auth</artifactId>
            <version>1.0.2</version>
            <optional>true</optional>
        </dependency>

Victor Martinez

unread,
Oct 1, 2015, 2:03:51 PM10/1/15
to Jenkins Developers
Awesome!If you need them only form testing then change their scope as test
Cheers

Jacqueline Taing

unread,
Oct 1, 2015, 2:14:58 PM10/1/15
to Jenkins Developers
How do you specify scope of dependency in pom.xml?

Thanks,
-jacqui

Victor Martinez

unread,
Oct 1, 2015, 4:42:34 PM10/1/15
to Jenkins Developers
There are a list of different dependency scopes, in your case you need to add the test scope tag. 

Further details: 

If you don't need that dependency in your runtime then use that test scope.

Cheers

Jacqueline Taing

unread,
Oct 1, 2015, 6:55:51 PM10/1/15
to Jenkins Developers
Thank you!
Reply all
Reply to author
Forward
0 new messages