Skip to content

Could not initialize class com.google.cloud.bigquery.datatransfer.v1.stub.GrpcDataTransferServiceStub #3492

@deepakstriim

Description

@deepakstriim

I'm trying to use BQ Data transfer client just to list supported data sources as an example but I'm seeing this error:
"java.lang.NoClassDefFoundError: Could not initialize class com.google.cloud.bigquery.datatransfer.v1.stub.GrpcDataTransferServiceStub"
This is my pom:

com.google.cloud
google-cloud-bigquerydatatransfer
0.55.1-beta


com.google.protobuf
protobuf-java
3.1.0

This is the sample code:

        Credentials credentials = GoogleCredentials
                .fromStream(new FileInputStream(credsFile));
//        googleCloudStorage = StorageOptions.newBuilder().setCredentials(credentials)
//                .setProjectId(projectId).build().getService();

        DataTransferServiceSettings transferServiceSettings = DataTransferServiceSettings.newBuilder()
                .setCredentialsProvider(FixedCredentialsProvider.create(credentials))
                .build();
        // Instantiate a client. If you don't specify credentials when constructing a client, the
        // client library will look for credentials in the environment, such as the
        // GOOGLE_APPLICATION_CREDENTIALS environment variable.
        try (DataTransferServiceClient client = DataTransferServiceClient.create(transferServiceSettings)) {
            // Request the list of available data sources.
            String parent = String.format("projects/%s", projectId);
            ListDataSourcesRequest request =
                    ListDataSourcesRequest.newBuilder()
                            .setParent(parent)
                            .build();
            ListDataSourcesPagedResponse response = client.listDataSources(request);

It throws error at the line where dts client is initialized:
DataTransferServiceClient.create(transferServiceSettings)

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions