GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ClassNotFoundException when using com.google.gcloud.AuthCredentials in 0.0.9 · Issue #260 · googleapis/google-cloud-java

ClassNotFoundException when using com.google.gcloud.AuthCredentials in 0.0.9 #260

New issue
Copy link
New issue
Copy link
Closed
Closed
ClassNotFoundException when using com.google.gcloud.AuthCredentials in 0.0.9#260
Copy link
Assignees
yoshi-automation
Labels
🚨 criticalP0 critical issue. Requires immediate fixtriage meI really want to be triaged.

Description

@simon-temple
simon-temple
opened on Oct 15, 2015
Issue body actions

I've just upgraded to 0.0.9 from 0.0.8-SNAPSHOT and I get

java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector

calling

AuthCredentials.createFor()

Activity

Next
  1. simon-temple commented on Oct 15, 2015

    @simon-temple
    simon-temple
    on Oct 15, 2015
    Author
    More actions

    For now I've added this to my POM but...

     <dependency>
                <groupId>net.sourceforge.cobertura</groupId>
                <artifactId>cobertura</artifactId>
                <version>2.1.1</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm-tree</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm-commons</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm-util</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm-analysis</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>oro</groupId>
                        <artifactId>oro</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>jaxen</groupId>
                        <artifactId>jaxen</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.ant</groupId>
                        <artifactId>ant</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.ant</groupId>
                        <artifactId>ant-junit</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>servlet-api-2.5</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty-util</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.sun</groupId>
                        <artifactId>tools</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>ch.qos.logback</groupId>
                        <artifactId>logback-classic</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.commons</groupId>
                        <artifactId>commons-lang3</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
  2. mziccard commented on Oct 15, 2015

    @mziccard
    mziccard
    on Oct 15, 2015
    Contributor
    More actions

    I tried but I couldn't reproduce your error.
    Could you share the complete stacktrace and the code you are using and possibly your pom.xml?
    Here is the simple code I tried:

    KeyStore keystore = KeyStore.getInstance("PKCS12");
    keystore.load(Files.newInputStream(Paths.get(PATH_TO_P12_KEYSTORE)), KEYSTORE_PASSWORD.toCharArray());
    PrivateKey privateKey = (PrivateKey) keystore.getKey("privatekey", KEYSTORE_PASSWORD.toCharArray());
    StorageOptions.Builder temp = StorageOptions.builder().projectId(PROJECT_ID)
        .authCredentials(AuthCredentials.createFor(EMAIL, privateKey));
    Storage storage = StorageFactory.instance().get(temp.build());
    for (BlobInfo info : storage.list(BUCKET)) {
      System.out.println(info);
    }

    And the pom.xml is:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.mycompany.app</groupId>
      <artifactId>my-app</artifactId>
      <packaging>jar</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>my-app</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        <dependency>
          <groupId>com.google.gcloud</groupId>
          <artifactId>gcloud-java</artifactId>
          <version>0.0.9</version>
        </dependency>
      </dependencies>
    </project>

    This seems to work here.

  3. simon-temple commented on Oct 15, 2015

    @simon-temple
    simon-temple
    on Oct 15, 2015
    Author
    More actions

    Section of my code:

    import com.google.gcloud.AuthCredentials;
    import com.google.gcloud.RetryParams;
    import com.google.gcloud.datastore.*;
    
    106: PrivateKey pk = PkiUtils.pkcs8PemDecode( pemPrivateKey );
    107: AuthCredentials credentials = AuthCredentials.createFor( clientId, pk );
    108: RetryParams retryParams = RetryParams.getDefaultInstance();
    109: options = DatastoreOptions.builder()
             .retryParams( retryParams )
             .authCredentials( credentials )
             .build();
    110: Datastore datastore = DatastoreFactory.instance().get( options );

    Part of my POM:

    <dependency>
        <groupId>com.google.gcloud</groupId>
        <artifactId>gcloud-java</artifactId>
        <version>0.0.9</version>
    </dependency>
    

    Stack trace:

    java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
        at com.google.gcloud.AuthCredentials.__cobertura_init(AuthCredentials.java)
        at com.google.gcloud.AuthCredentials.<clinit>(AuthCredentials.java)
        at com.acme.prod.core.persist.gce.GCEPersistentStorage.init(GCEPersistentStorage.java:107)
        at com.acme.prod.core.persist.gce.GCEPersistentStorage.create(GCEPersistentStorage.java:59)
        at com.acme.prod.core.persist.StorageFactory.create(StorageFactory.java:37)
        at com.acme.prod.core.persist.StorageFactory.create(StorageFactory.java:28)
        at com.acme.prod.app.App.main(App.java:70)
    Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector
        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)
        ... 7 more","class":"java.lang.Throwable$WrappedPrintStream
    

    I found a cobertura.properties file in the root of gcloud-java-core-0.0.9.jar

    #Generated by maven-cobertura-plugin for project com.google.gcloud:gcloud-java-core:jar:0.0.9
    #Fri Oct 09 00:08:23 UTC 2015
    net.sourceforge.cobertura.datafile=/home/travis/build/GoogleCloudPlatform/gcloud-java/gcloud-java-core/target/cobertura/cobertura.ser
    

    Decompiling the AuthCredentials class in gcloud-java-core-0.0.9.jar I see:

    import net.sourceforge.cobertura.coveragedata.LightClassmapListener;
    import net.sourceforge.cobertura.coveragedata.TouchCollector;
    
    public abstract class AuthCredentials
      implements Serializable
    {
      public static final transient int[] __cobertura_counters;
    ...
  4. mziccard commented on Oct 15, 2015

    @mziccard
    mziccard
    on Oct 15, 2015
    Contributor
    More actions

    You are right, I was using a locally installed artifact that does not have that problem.
    Must be an issue with our deploy process, cobertura stuff remains in deployed class files. I will look into it, sorry for inconvenient, I'll keep you posted.

  5. mziccard commented on Oct 15, 2015

    @mziccard
    mziccard
    on Oct 15, 2015
    Contributor
    More actions

    This problem seems to have started with 0.0.9. To add some background:

    • mvn compile compiles classes in target/classes.
    • mvn cobertura:cobertura instruments classes and places the compiled ones into target/generated-classes/cobertura. In target/generated-classes/cobertura we have class files and a cobertura.properties file.

    Looking at the deployed jars it seems that they are being generated from the class files in target/generated-classses/cobertura: they contain cobertura.properties and classes contain cobertura code (see the decompiled AuthCredentails here).

    The problem comes from mvn site which (I don't know why) creates the jars for the classes in target/generated-classes/cobertura. The mvn deploy command then deploys these jars.
    I think this issue could be solved by replacing the line here with:

    mvn clean deploy -DskipTests=true --settings target/travis/settings.xml -P sign-deploy
    

    That should delete wrong jars and force building new ones. @ajkannan @aozarov what do you think?

    Thanks again to @simon-temple for spotting this!

  6. simon-temple commented on Oct 15, 2015

    @simon-temple
    simon-temple
    on Oct 15, 2015
    Author
    More actions

    Thank you. Please keep me updated about any 0.0.10 release.
    We're getting ready to system test a product and I'd rather not run with cobertura instrumented JARs

  7. ajkannan commented on Oct 15, 2015

    @ajkannan
    ajkannan
    on Oct 15, 2015
    More actions

    Since we copy the signing tools into the directory target/travis, those will get erased by clean before they can be used to deploy. As long as we move those to another location, this fix sounds good to me.

  8. ajkannan commented on Oct 15, 2015

    @ajkannan
    ajkannan
    on Oct 15, 2015
    More actions

    I'm assigning myself the issue, and I'll test @mziccard's solution.

  9. ajkannan
    self-assigned this
    on Oct 15, 2015
  10. mziccard commented on Oct 15, 2015

    @mziccard
    mziccard
    on Oct 15, 2015
    Contributor
    More actions

    Thanks @ajkannan, you are right, we might need to move signing tools elsewhere, but that should no be an issue.

  11. aozarov
    closed this as completedin #263on Oct 15, 2015
  12. mziccard commented on Oct 15, 2015

    @mziccard
    mziccard
    on Oct 15, 2015
    Contributor
    More actions

    @simon-temple We fixed the issue and deployed version 0.0.10!

  13. simon-temple commented on Oct 16, 2015

    @simon-temple
    simon-temple
    on Oct 16, 2015
    Author
    More actions

    Thanks for the quick turnaround.

    One other packaging question...

    I'm having to add this to my POM:

    <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>18.0</version>
    </dependency>
    

    to avoid this:

    java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects
    at com.google.gcloud.RetryParams.toString(RetryParams.java:284)
    at java.lang.String.valueOf(String.java:2994)
    at java.lang.StringBuilder.append(StringBuilder.java:131)
    at com.acme.app.core.persist.gce.GCEPersistentStorage.init(GCEPersistentStorage.java:120)
    at com.acme.app.core.persist.gce.GCEPersistentStorage.create(GCEPersistentStorage.java:59)
    at com.acme.app.core.persist.PersistentStorageFactory.create(PersistentStorageFactory.java:37)
    at com.acme.app.core.persist.PersistentStorageFactory.create(PersistentStorageFactory.java:28)
    at com.acme.app.app.App.main(App.java:70)
    Caused by: java.lang.ClassNotFoundException: com.google.common.base.MoreObjects
    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)
    ... 8 more","class":"java.lang.Throwable$WrappedPrintStream
    

    If the gcloud POM dependencies are correct shouldn't it be included by maven when it resolves all my dependencies?

  14. mziccard commented on Oct 16, 2015

    @mziccard
    mziccard
    on Oct 16, 2015
    Contributor
    More actions

    guava is not added as a compile dependency in our POMs so maven should be able to resolve it automatically for your project.

    I tried with the simple setup described previously in #260 (comment):

    • deleted my local repo with
      rm -rf ~/.m2/repository/com/google/guava ~/.m2/repository/com/google/gcloud
    • mvn compile
    • mvn exec:java -Dexec.mainClass="com.mycompany.app.App"

    At mvn compile I see guava being downloaded and installed, mvn exec... then runs the app smoothly.

  15. simon-temple commented on Oct 16, 2015

    @simon-temple
    simon-temple
    on Oct 16, 2015
    Author
    More actions

    Looks like my problem, sorry.

    I have a com.googlecode.objectify dependency in the same project. It holds the dependency on guava 18.0. Not sure why maven chooses objectify as the owner of guava over gcloud...?

    When I exclude com.googlecode.objectify from my final target it drops guava... even though gcloud-core has it as a dependency.

    ...any way. My bad and thanks for looking.

  16. 26 remaining items

  17. github-actions
    added 2 commits that reference this issue on Oct 5, 2022

    chore(main): release 2.2.8 (#270)

    7e3e72d

    chore(deps): update dependency com.google.cloud:google-cloud-filestor…

    aa82336
  18. github-actions
    added a commit that references this issue on Nov 8, 2022

    chore(java): add a note in README for migrated split repos (googleapi…

    3fe4fcc
  19. github-actions
    added a commit that references this issue on Nov 19, 2022

    chore(java): add a note in README for migrated split repos (googleapi…

    a401b30
  20. meltsufin
    added a commit that references this issue on Dec 22, 2025

    build(java): use yoshi-approver token for auto-approve (#260)

    716219c
  21. chingor13
    added a commit that references this issue on Jan 6, 2026

    chore: release 0.119.0 (#260)

    e7753e6
  22. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore: release 1.105.2-SNAPSHOT (#260)

    1d807e6
  23. chingor13
    added a commit that references this issue on Feb 24, 2026

    chore: fix license on token verifier classes (#461)

    This issue will close once commit 4e33076 is merged into the 'main' branch.
    4e33076
  24. suztomo
    added a commit that references this issue on Mar 11, 2026

    build(java): use yoshi-approver token for auto-approve (googleapis#260)

    70e89e3
  25. chingor13
    added a commit that references this issue on Mar 12, 2026

    chore: fix license on token verifier classes (#461)

    This issue will close once commit d9c5c05 is merged into the 'main' branch.
    d9c5c05
  26. suztomo
    added a commit that references this issue on Mar 23, 2026

    deps: update dependency com.google.cloud:google-cloud-spanner-bom to …

    547c678
  27. suztomo
    added 2 commits that reference this issue on Mar 30, 2026

    deps: update dependency com.google.cloud:google-cloud-shared-dependen…

    e1c4b7c

    chore: release 0.122.0 (#277)

    b3b4d60
  28. lqiu96
    added 2 commits that reference this issue on Apr 1, 2026

    deps: update dependency com.google.cloud:google-cloud-shared-dependen…

    145656b

    chore: release 0.122.0 (#277)

    fe0f517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @yoshi-automation
    yoshi-automation

Labels

🚨 criticalP0 critical issue. Requires immediate fixtriage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.