googleapis / java-bigtable

Apache License 2.0
71 stars 88 forks source link

BigTable API - Error connecting to BigTable Emulator #2200

Open spachari-im opened 7 months ago

spachari-im commented 7 months ago

Can you please help me identify why BigTable API fails to connect with BigTable emulator running on Docker?

Environment details

  1. Specify the API at the beginning of the title - BigTable
  2. OS type and version: Mac
  3. Java version: 17
  4. bigtable version(s): Docker BigTable

Steps to reproduce

  1. Start gcloud BigTable emulator in local Docker.
  2. Run the basic Read example - https://github.com/googleapis/java-bigtable/blob/main/samples/snippets/src/main/java/com/example/bigtable/Reads.java

Code example

    <dependencyManagement>
        <dependencies>
           <dependency>
                <groupId>com.google.cloud</groupId>
                <artifactId>libraries-bom</artifactId>
                <version>26.37.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
         ......
        </dependencies>
    </dependencyManagement>
.....
<dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-bigtable</artifactId>
        </dependency>
try (BigtableTableAdminClient adminClient =
                 BigtableTableAdminClient.create(projectId, instanceId)) {
            CreateTableRequest createTableRequest =
                CreateTableRequest.of(tableId)
                                  .addFamily(COLUMN_FAMILY_NAME_STATS)
                                  .addFamily(COLUMN_FAMILY_NAME_PLAN);
            adminClient.createTable(createTableRequest);
        } catch (IOException e) {
            System.out.println("Error during createTable: \n" + e.toString());
            throw (e);
        }

Stack trace

INFO: Connecting to the Bigtable emulator at localhost:8086
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Verify
    at com.google.cloud.bigtable.admin.v2.BigtableTableAdminSettings.<init>(BigtableTableAdminSettings.java:66)
    at com.google.cloud.bigtable.admin.v2.BigtableTableAdminSettings.<init>(BigtableTableAdminSettings.java:53)
    at com.google.cloud.bigtable.admin.v2.BigtableTableAdminSettings$Builder.build(BigtableTableAdminSettings.java:265)
    at com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.create(BigtableTableAdminClient.java:151)
    at com.thinknear.venice.dao.gcp.BigTableClientTest.createTable(BigTableClientTest.java:63)
    at com.thinknear.venice.dao.gcp.BigTableClientTest.main(BigTableClientTest.java:39)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Verify
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 6 more

External references such as API reference guides

igorbernstein2 commented 5 months ago

It seems like you might some dependency conflicts that override the gauva version? Please attach the output of mvn dependency:tree to this issue