Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Error when connect to Hbase Cluster Using Java Client: Can't get the locations

Error when connect to Hbase Cluster Using Java Client: Can't get the locations

New Contributor

My hbase cluster have 1 master & 2 regional servers (running in fully distributed mode). I am able to connect & create table using hbase shell.

However, when using java client connect to the cluster, I got below error:

 

6:20:10 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:host.name=master
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:java.version=1.7.0_51
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:java.home=/usr/java/jdk1.7.0_51/jre
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:java.class.path=/usr/local/apache-maven/boot/plexus-classworlds-2.4.jar
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/tmp
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA>
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:os.arch=amd64
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:os.version=2.6.32-504.el6.x86_64
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:user.name=steven.tran
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:user.home=/home/JOBST/steven.tran
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Client environment:user.dir=/home/JOBST/steven.tran/asas
15/09/20 16:20:10 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=10.10.40.17:2181 sessionTimeout=90000 watcher=hconnection-0xa92b535, quorum=10.10.40.17:2181, baseZNode=/hbase
15/09/20 16:20:10 INFO zookeeper.ClientCnxn: Opening socket connection to server 10.10.40.17/10.10.40.17:2181. Will not attempt to authenticate using SASL (unknown error)
15/09/20 16:20:10 INFO zookeeper.ClientCnxn: Socket connection established to 10.10.40.17/10.10.40.17:2181, initiating session
15/09/20 16:20:10 INFO zookeeper.ClientCnxn: Session establishment complete on server 10.10.40.17/10.10.40.17:2181, sessionid = 0x14fdfa7a8ec003a, negotiated timeout = 40000
Creating table. 15/09/20 16:21:11 INFO client.ConnectionManager$HConnectionImplementation: Closing zookeeper sessionid=0x14fdfa7a8ec003a
15/09/20 16:21:11 INFO zookeeper.ZooKeeper: Session: 0x14fdfa7a8ec003a closed
15/09/20 16:21:11 INFO zookeeper.ClientCnxn: EventThread shut down
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.hadoop.hbase.client.RetriesExhaustedException: Can't get the locations
at org.apache.hadoop.hbase.client.RpcRetryingCallerWithReadReplicas.getRegionLocations(RpcRetryingCallerWithReadReplicas.java:307)
at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas.call(ScannerCallableWithReplicas.java:131)
at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas.call(ScannerCallableWithReplicas.java:56)
at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithoutRetries(RpcRetryingCaller.java:200)
at org.apache.hadoop.hbase.client.ClientScanner.call(ClientScanner.java:287)
at org.apache.hadoop.hbase.client.ClientScanner.nextScanner(ClientScanner.java:267)
at org.apache.hadoop.hbase.client.ClientScanner.initializeScannerInConstruction(ClientScanner.java:139)
at org.apache.hadoop.hbase.client.ClientScanner.<init>(ClientScanner.java:134)
at org.apache.hadoop.hbase.client.HTable.getScanner(HTable.java:825)
at org.apache.hadoop.hbase.MetaTableAccessor.fullScan(MetaTableAccessor.java:606)
at org.apache.hadoop.hbase.MetaTableAccessor.tableExists(MetaTableAccessor.java:370)
at org.apache.hadoop.hbase.client.HBaseAdmin.tableExists(HBaseAdmin.java:281)
at HbaseTest.createOrOverwrite(HbaseTest.java:22)
at HbaseTest.createSchemaTables(HbaseTest.java:37)
at HbaseTest.main(HbaseTest.java:45)

 

According to the log, it seem that the java client successfully connected to the zookeeper. Kindly seeking your help.

7 REPLIES 7

Re: Error when connect to Hbase Cluster Using Java Client: Can't get the locations

Master Guru
Your client does progress beyond the ZK cluster (meta) discovery stage but, per the trace, is unable to talk to the meta-hosting region server, or a sub-error thereof.

Are you able to scan data from the shell for the same table, and are you running the program on the same host you ran the shell commands on?

Re: Error when connect to Hbase Cluster Using Java Client: Can't get the locations

New Contributor

Hi Harsh,

 

My Client is tried to create a new table and the process failed at this stage. Below is my client code:

 

public class HbaseTest {
private static final String TABLE_NAME = "MY_TABLE_NAME_TOO";
private static final String CF_DEFAULT = "DEFAULT_COLUMN_FAMILY";
public static void main(String... args) throws IOException {
Configuration config = HBaseConfiguration.create();
config.set("zookeeper.znode.parent", "/hbase");
//config.set("hbase.zookeeper.quorum", "master");
try (Connection connection = ConnectionFactory.createConnection(config);
Admin admin = connection.getAdmin()) {
HTableDescriptor table = new HTableDescriptor(TableName.valueOf(TABLE_NAME));
table.addFamily(new HColumnDescriptor(CF_DEFAULT).setCompressionType(Algorithm.LZ4));
System.out.print("Creating table. ");
if (admin.tableExists(table.getTableName())) {
admin.disableTable(table.getTableName());
admin.deleteTable(table.getTableName());
}
admin.createTable(table);
System.out.println(" Done.");
}
}
}

Here is the steps that I followed to set up the hbase cluster: https://docs.google.com/document/d/1cmV4-ZaragjqLzXwEr5woI8X1OhN6TT5mmz_Q8ccnKw/edit?usp=sharing

 

 

Re: Error when connect to Hbase Cluster Using Java Client: Can't get the locations

New Contributor

Has there been a resoltuion to this issue?

Re: Error when connect to Hbase Cluster Using Java Client: Can't get the locations

Master Guru
Usually what this ends up being is a misconfiguration of the client, or an
environment fault. If you find your client resolving the meta RS location,
but then freezing or erroring out, then the cause may either be lack of
proper configs in the runtime classpath (no proper /etc/hbase/conf/ on
classpath) or a connectivity issue (client host cannot reach or completely
talk to 60020 and 60000 in the cluster for RS and Master hosts
respectively).

Re: Error when connect to Hbase Cluster Using Java Client: Can't get the locations

New Contributor

what is the proper set of configuration settings to connect to a remote HBASE from a Java client running on the Windows machine?

I have the following properties defined but getting the same exception:

 

Configuration conf = HBaseConfiguration.create();
conf.set("hbase.rootdir", "hdfs://<my host name>:60000/hbase");
conf.setBoolean("hbase.cluster.distributed", true);
conf.setInt("hbase.client.scanner.caching", 10000);
conf.set("zookeeper.znode.parent", "/hbase");

 

Thank you

Re: Error when connect to Hbase Cluster Using Java Client: Can't get the locations

Master Guru
Assuming no security, you only need the "hbase.zookeeper.quorum" property
for a HBase client to discover your cluster.

I would not recommend hardcoding configs in code. Its far more easier to
grab the client hbase-site.xml from the cluster and place it on your
application classpath (under src/main/resources if you use maven and
assemble jars).

Re: Error when connect to Hbase Cluster Using Java Client: Can't get the locations

Explorer

Hi,

 

I have been getting the same error. I am getting the configuration files from the cluster and using in the code but here in our case we have edge nodes. How can I connect from a client using Java API for this case?

Don't have an account?
Coming from Hortonworks? Activate your account here