5

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.

riorio
  • 5,015
  • 5
  • 29
  • 70
  • This issue may be related: https://github.com/googleapis/java-pubsub/issues/217 – Sergei Jul 02 '20 at 07:22
  • Looks like some of the dependencies still uses the old `grpc` version. Please check also these comments: https://github.com/grpc/grpc-java/issues/7002#issuecomment-623778715 https://github.com/grpc/grpc-java/issues/7002#issuecomment-624187358 to list the dependency tree in project and to make sure 1.29 version is used everywhere. Then re-import project in IDE Gradle tool window. – Andrey Jul 03 '20 at 07:24

2 Answers2

0

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.

kaan
  • 3,045
  • 2
  • 11
  • 31
0

In my case explicitly adding

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

has helped. (I was using grpcVersion 1.35.0)

Sergey Shcherbakov
  • 3,584
  • 2
  • 30
  • 48