我正在尝试使用HBase API连接到Google Cloud Bigtable实例。我正在使用Java 1.8。我遵循以下教程:

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

但是由于某种原因,我无法连接到此Bigtable实例。我正在使用有效的ProjectID和InstanceID,但仍然无法连接。请在下面找到例外:

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)


以下是我的Maven依赖项:

<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>


由于这是一个Spring-boot应用程序,因此还存在其他依赖项。

同样,在这种情况下,ProjectID和InstanceID具有相同的值。

有人可以让我知道这里的问题吗?

最佳答案

对于它的价值,我的org.apache.hbase版本是1.2.4
另外我怀疑由于您的项目ID等于实例ID,因此您指的是ProjectID别名,而不是实际的基础名称,因为我认为是自动分配的?我在使用Project别名的其他地方遇到了问题,而google似乎期望底层ID。但是查看异常似乎不是问题所在...

关于java - 无法连接到Google Cloud Bigtable实例,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41337698/

10-10 23:34