Home Forums HBase problem with Simple Java client on Cent OS running on HDP 2

This topic contains 5 replies, has 3 voices, and was last updated by  Jeffrey Zhong 1 year ago.

  • Creator
  • #43905


    On Oracle Virtual box, created a VM and installed Cent OS and all HDP 2.0 components. When running the below simple java application, the application freezes when the code to create HTable is called. From error message, it looks like not able to find region server/region.What I am missing?
    package main.java;
    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.hbase.HBaseConfiguration;
    import org.apache.hadoop.hbase.client.HTable;
    import org.apache.hadoop.hbase.client.Put;
    import org.apache.hadoop.hbase.util.Bytes;
    import java.io.IOException;

    public class TestHbaseInsert {
    public static void main(String[] args) throws IOException {
    Configuration conf = HBaseConfiguration.create();
    HTable table = new HTable(conf, “testtable”);
    Put put = new Put(Bytes.toBytes(“row1″));
    put.add(Bytes.toBytes(“colfam1″), Bytes.toBytes(“qual1″),
    put.add(Bytes.toBytes(“colfam1″), Bytes.toBytes(“qual2″),
    /usr/java/default/bin/java -agentlib:jdwp=transport=dt_socket,address=,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath
    0x307b4703 connecting to ZooKeeper ensemble=localhost:2181
    2013-11-17 22:55:12,761 INFO [main-SendThread(node10.nw.com:2181)] zookeeper.ClientCnxn (ClientCnxn.java:logStartConnect(966)) – Opening socket connection to server node10.nw.com/ Will not attempt to authenticate using SASL (java.lang.SecurityException: Unable to locate a login configuration)
    2013-11-17 22:55:12,777 INFO [main-SendThread(node10.nw.com:2181)] zookeeper.ClientCnxn (ClientCnxn.java:primeConnection(849)) – Socket connection established to node10.nw.com/, initiating session
    2013-11-17 22:55:12,818 INFO [main-SendThread(node10.nw.com:2181)] zookeeper.ClientCnxn (ClientCnxn.java:onConnected(1211)) – Session establishment complete on server node10.nw.com/, sessionid = 0x14269f4f96b001a, negotiated timeout = 40000
    2013-11-17 22:55:12,838 INFO [main] client.ZooKeeperRegistry (ZooKeeperRegistry.java:getClusterId(85)) – ClusterId read in ZooKeeper is null

    Exception in thread “main” org.apache.hadoop.hbase.client.NoServerForRegionException: Unable to find region for after 35 tries.
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1127)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:1047)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:1004)
    at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:325)
    at org.apache.hadoop.hbase.client.HTable.(HTable.java:191)
    at org.apache.hadoop.hbase.client.HTable.(HTable.java:149)
    at main.java.TestHbaseInsert.main(TestHbaseInsert.java:16)
    Disconnected from the target VM, address: ‘′, transport: ‘socket’
    Process finished with exit code

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

  • Author
  • #44076

    There is a some typo, log4j.rootLogger=INFO,RFA should be as following:



    I tried your script and it runs fine.

    It seems your Region Server wasn’t running. Could you please enable the debug log by setting log4j.rootLogger=INFO,RFA from “log4j.rootLogger=${hbase.root.logger}” in file /usr/lib/hbase/conf/log4j.properties?

    After configuration change, you need to restart HBase using hbase user:

    1) [hbase@sandbox ~]$ cd /usr/lib/hbase

    ./bin/hbase-daemon.sh stop regionserver
    ./bin/hbase-daemon.sh stop master
    ./bin/hbase-daemon.sh start master
    ./bin/hbase-daemon.sh start regionserver

    3) use hbase shell to send some sample puts to testtable. If it’s good, then try your sample client code

    The java command I’m using is:

    java -cp `hbase classpath` TestHbaseInsert


    Enis Soztutar

    The problem might be that you do not have Hbase configuration files in your classpath. Your application should have /etc/hbase/conf as a part of the classpath, so that Hbase can read the hbase-site.xml and other configuration files from there.



    Thanks for helping me with this.
    hbase(main):003:0> describe ‘testtable’
    ‘testtable’, {NAME => ‘colfam1′, DATA_BLOCK_ENCODIN true
    E => ‘0’, VERSIONS => ‘1’, COMPRESSION => ‘NONE’, M
    IN_VERSIONS => ‘0’, TTL => ‘2147483647’, KEEP_DELET
    ED_CELLS => ‘false’, BLOCKSIZE => ‘65536’, IN_MEMOR
    Y => ‘false’, ENCODE_ON_DISK => ‘true’, BLOCKCACHE
    => ‘true’}
    1 row(s) in 0.9150 seconds


    Have you created testtable table already before you run the above client code? If you already created the table, please paste your table definition here using describe command in hbase shell.


Viewing 5 replies - 1 through 5 (of 5 total)