title: Unable to Connect to HBase 0.96.1.1-hadoop2 Standalone in Java
body: <p>My problem is that I am attempting to connect to a standalone HBase instance using Java and the program just hangs indefinitely.</p>
  
  <p>I have set up a fresh instance of HBase 0.96.1.1-hadoop2 and Hadoop 2.2.0 on an iMac running OS X 10.8.5. It seems that both are running fine in the sense that I can access the web ui's normally (e.g. localhost:60010 for HBase) without a hitch. </p>
  
  <p>Running jps gives me this:</p>
  
  <pre><code>bash-3.2$ jps
  77164 SecondaryNameNode
  81089 Jps
  80685 HMaster
  77360 NodeManager
  77273 ResourceManager
  77061 DataNode
  76975 NameNode
  </code></pre>
  
  <p>I am able to use HBase shell to create and scan tables as in the examples on the HBase Quick start guide. I am also running Hbase and Hadoop with the same user (not sure if this matters or not).</p>
  
  <p>Here is the Java program I am trying to run:</p>
  
  <pre><code>package com.mypackage.dao.hbase;
  
  import java.io.IOException;
  
  import org.apache.hadoop.fs.Path;
  import org.apache.hadoop.hbase.HBaseConfiguration;
  import org.apache.hadoop.hbase.client.HConnection;
  import org.apache.hadoop.hbase.client.HConnectionManager;
  import org.apache.hadoop.hbase.client.HTableInterface;
  import org.apache.hadoop.hbase.client.Put;
  import org.apache.hadoop.hbase.util.Bytes;
  import org.apache.hadoop.conf.Configuration;
  
  public class HBaseDao {
  
      private static final String DICTIONARY_TABLE = "mytable";
      private static final String DICTIONARY_CF = "mycf";
      private static final String DICTIONARY_CF_TYPE = "type";
  
      private final Configuration conf;
  
      public HBaseDao() throws IOException {
          Configuration config = HBaseConfiguration.create();
          config.clear();
          config.set("hbase.zookeeper.quorum", "localhost");
          config.set("hbase.zookeeper.property.clientPort","2181");
          config.set("hbase.master", "localhost:60000");
          config.addResource(new Path("/usr/local/hbase/hbase/conf/hbase-site.xml"));
          this.conf = config;
      }
  
      public void addNameToTable(HTableInterface table, String name, String type) throws IOException {
          Put p = new Put(Bytes.toBytes(name)); 
          p.add(Bytes.toBytes(DICTIONARY_CF),
                    Bytes.toBytes(DICTIONARY_CF_TYPE),
                    Bytes.toBytes(type));
          System.out.println("About to put");
          table.put(p);
      }
  
  
      public void loadDictionaryIntoTable() throws IOException {
          HConnection connection = HConnectionManager.createConnection(this.conf);
          HTableInterface table = connection.getTable(DICTIONARY_TABLE);
           try {
              // Use the table as needed, for a single operation and a single thread
               String s = "TestName2";
               String t = "TestType2";
               addNameToTable(table,s,t);
           } finally {
          System.out.println("Got here");  
             table.close();
             connection.close();
           }
      }
  
      public static void main(String[] args) throws IOException {
  
          HBaseDao dao = new HBaseDao();
          dao.loadDictionaryIntoTable();
      }
  }
  </code></pre>
  
  <p>Finally, I have this dependency in my pom file:</p>
  
  <pre><code>&lt;dependency&gt;
   &lt;groupId&gt;org.apache.hbase&lt;/groupId&gt;
   &lt;artifactId&gt;hbase-client&lt;/artifactId&gt;
   &lt;version&gt;0.96.1.1-hadoop2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>The output I am seeing is this:</p>
  
  <pre><code>Ok we started 
  log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory). 
  log4j:WARN Please initialize the log4j system properly. 
  log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 
  SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6] 
  SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details. 
  2014-01-28 16:19:48.453 java[81102:1903] Unable to load realm info from SCDynamicStore
  </code></pre>
  
  <p>And it just hangs indefinitely...</p>