HBase Forum

problem with Simple Java client on Cent OS running on HDP 2

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

to create new topics or reply. | New User Registration

  • Author
  • #44014
    Jeffrey Zhong

    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.



    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

    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.

    Jeffrey Zhong

    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

    Jeffrey Zhong

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


You must be to reply to this topic. | Create Account

Support from the Experts

A HDP Support Subscription connects you experts with deep experience running Apache Hadoop in production, at-scale on the most demanding workloads.

Enterprise Support »

Become HDP Certified

Real world training designed by the core architects of Hadoop. Scenario-based training courses are available in-classroom or online from anywhere in the world

Training »

Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.