Skip to content

throws java.lang.NoClassDefFoundError: com/google/auth/Credentials  #1071

@skystar7

Description

@skystar7

In which file did you encounter the issue?

java-docs-samples/speech/cloud-client/src/main/java/com/example/speech/QuickstartSample.java

Describe the issue

throwing

Exception in thread "Thread-5" java.lang.NoClassDefFoundError: com/google/auth/Credentials
        at com.tigerfixonline.demoMaven.RecorderGUI.lambda$null$2(RecorderGUI.java:70)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.google.auth.Credentials
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more
Finished

Did you change the file? If so, how?

edited to this code to be constructed with myJSON :

 // Instantiates a client
        CredentialsProvider credentialsProvider = FixedCredentialsProvider.create(ServiceAccountCredentials.fromStream(new FileInputStream("MyJSON.json")));
        SpeechSettings settings = SpeechSettings.newBuilder().setCredentialsProvider(credentialsProvider).build();
        StringBuilder stringBuilder;
        try (SpeechClient speechClient = SpeechClient.create(settings)) { ...}

My POM

 <properties>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

 <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-speech</artifactId>
            <version>0.41.0-alpha</version>
        </dependency>
    </dependencies>

Is anyone experiencing the same issue?

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions