Skip to content

NoClassDefFoundError when using service account credentials #1045

@sebphil

Description

@sebphil

I'm using the following code to initialize the firebase admin sdk:

GoogleCredentials credentials = GoogleCredentials.fromStream(credentialsStream, () -> transport)
                .createScoped(myProperties.getScopes());
FirebaseOptions options = FirebaseOptions.builder()
                .setCredentials(credentials)
                .setHttpTransport(transport)
                .build();

The credentialsStream I'm injecting is read from a service account file.
This code, which worked fine in 9.4.1, now fails in 9.4.2 with the followin error:
java.lang.NoClassDefFoundError: com/google/auth/CredentialTypeForMetrics

As far as I can tell, this issue is caused by a dependency conflict between the following libs:

  • google-api-client:2.7.0
    • google-auth-library-credentials:1.23.0
  • google-auth-library-oauth2-http:1.29.0
    • google-auth-library-credentials:1.29.0

maven selects google-auth-library-credentials:1.23.0 which causes the ServiceAccountCredentials class to fail to load due to the CredentialTypeForMetrics class only existing since google-auth-library-credentials version 1.28.0.

Adding an explicit dependency to google-auth-library-credentials:1.29.0 in my maven project seems to workaround the issue.

Sub-issues

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions