ClassNotFoundException: io.grpc.internal.BaseDnsNameResolverProvider when trying to create a BigtableDataClient from Windows

Viewed 4628

When spinning up a Spring boot application on Intellij, that tries to connect the GCP's BigTable, we get the following error: java.lang.NoClassDefFoundError: io/grpc/internal/BaseDnsNameResolverProvider

This is the stack trace:


...nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.google.cloud.bigtable.data.v2.BigtableDataClient]: Factory method 'bigtableDataClient' threw exception; nested exception is java.lang.NoClassDefFoundError: io/grpc/internal/BaseDnsNameResolverProvider
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:227) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
           ....

The import in Gradle is:

implementation 'com.google.cloud:google-cloud-bigtable:1.13.0'

Update:

I tried to specifically use a different grpc-alt version:

compile group: 'io.grpc', name: 'grpc-alts', version: '1.29.0' But it did not help.

If I try to run the app from the Gradle command of bootRun it spins up with no problem. Only when trying to start it in the Intellij it faces the same issue.

2 Answers

Here's a workaround: use version 1.28.1 for all grpc components.

While there are other versions currently available (1.29.0, 1.30.0, 1.30.1, 1.30.2 per https://mvnrepository.com/artifact/io.grpc), they exhibit the same error – java.lang.NoClassDefFoundError: io/grpc/internal/BaseDnsNameResolverProvider – in my local tests.

In my case explicitly adding

implementation group: 'io.grpc', name: 'grpc-core', version: "${grpcVersion}"

has helped. (I was using grpcVersion 1.35.0)

Related