1
votes

I am trying to connect to a Google Cloud Bigtable instance using HBase APIs. I am using Java 1.8. I followed the below tutorials:

https://cloud.google.com/bigtable/docs/samples-java-hello https://cloud.google.com/bigtable/docs/using-maven

But for some reason I am unable to connect to this Bigtable instance. I am using valid ProjectID and InstanceID but still I am unable to connect. Please find the exception below:

java.lang.IllegalStateException: Could not find an appropriate constructor for com.google.cloud.bigtable.hbase1_2.BigtableConnection
    at com.google.cloud.bigtable.hbase.BigtableConfiguration.connect(BigtableConfiguration.java:88)
    at com.google.cloud.bigtable.hbase.BigtableConfiguration.connect(BigtableConfiguration.java:72)
    at com.kp.sensor.iot.IOTSensorPull.makeConnection(IOTSensorPull.java:149)
    at com.kp.sensor.iot.IOTSensorPull.populateTemperature(IOTSensorPull.java:159)
    at com.kp.sensor.iot.IOTSensorPull.readMessagesFromRFIDSub(IOTSensorPull.java:126)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.google.cloud.bigtable.hbase.BigtableConfiguration.connect(BigtableConfiguration.java:85)
    ... 18 more
Caused by: java.lang.NoSuchMethodError: com.google.cloud.bigtable.config.BigtableOptions$Builder.setInstanceId(Ljava/lang/String;)Lcom/google/cloud/bigtable/config/BigtableOptions$Builder;
    at com.google.cloud.bigtable.hbase.BigtableOptionsFactory.fromConfiguration(BigtableOptionsFactory.java:244)
    at org.apache.hadoop.hbase.client.AbstractBigtableConnection.<init>(AbstractBigtableConnection.java:129)
    at org.apache.hadoop.hbase.client.AbstractBigtableConnection.<init>(AbstractBigtableConnection.java:104)
    at com.google.cloud.bigtable.hbase1_2.BigtableConnection.<init>(BigtableConnection.java:50)

Below are my maven dependencies:

<dependency>
    <groupId>com.google.cloud.bigtable</groupId>
    <artifactId>bigtable-hbase-1.2</artifactId>
    <version>0.9.4</version>
</dependency>

<dependency>
    <groupId>org.apache.hbase</groupId>
    <artifactId>hbase-client</artifactId>
    <version>1.1.5</version>
</dependency>

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-tcnative-boringssl-static</artifactId>
    <version>1.1.33.Fork19</version>
</dependency>

There are other dependencies as well since this is a Spring-boot application.

Also, in this case the ProjectID and InstanceID have the same value.

Can someone please let me know what could be the issue here?

2
I've seen this kind of thing happen when there are multiple conflicting versions of bigtable-* artifacts are on the classpath. Could that be the problem in your case?Solomon Duskis

2 Answers

1
votes

For what it's worth, my version for org.apache.hbase is 1.2.4 Also I suspect that since your project ID equals Instance ID, you are referring to the ProjectID alias, rather than the actual underlying name, since I think that one is auto-assigned? I've had issues elsewhere where using the Project alias, wile google seems to expect the underlying ID. But looking at the exceptions seems the problem is not with that...

1
votes

Actually I think I found another reason behind this, which is probably more relevant: i noticed that when bigtable-hbase-1.2-0.9.4.jar is not located precisely in the original path of '/com/google/cloud/bigtable/bigtable-hbase-1.2/0.9.4/bigtable-hbase-1.2-0.9.4.jar' this problem will occur, as the code seems to check the version number of 1.2 (based on the parent folder?)

In my case, this seems to be related specifically to Bigtable-Dataflow portion of the API, and NOT to the general Bigtable API (i.e. bigtable-hbase-dataflow in POM.xml). The generic part of Bigtable API seems not to care where the JAR is located.

I came across this while testing on Google's VMs, where I was dumping all JARs just into one directory for simplicity. It worked well for the generic Bigtable functionality, but NOT for the Bigtable-Dataflow functionality, even though it worked on my local machine, where Eclipse built all dependency paths properly before launching the code. As soon as I put that .JAR in the proper path, the problem was gone.

I'm guessing the complication is coming from somewhere here?
https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/master/bigtable-hbase-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/BigtableConfiguration.java#L43

cc: @solomon-duskis