来自java的hbase连接出错

时间:2013-08-18 12:57:03

标签: java hbase

我尝试从java连接本地模式的HBase但是在调试时报告错误。我的代码:

import java.io.IOException;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.conf.Configuration;


public class MyLittleHBaseClient {
  public static void main(String[] args) throws IOException {

    Configuration config = HBaseConfiguration.create();
    HTable table = new HTable(config, "test");
    ....

和错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:129)
at mylittlehbaseclient.MyLittleHBaseClient.main(MyLittleHBaseClient.java:32)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

1 个答案:

答案 0 :(得分:1)

您需要在项目的类路径中使用commons-logging库。