nemigam
nemigam

Reputation: 11

Error in hbase connection from java

I am try to connect HBase in local mode from java But in debug time an error is reported. My code:

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");
    ....

and error:

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)

Upvotes: 1

Views: 757

Answers (1)

user2030471
user2030471

Reputation:

You need commons-logging library in the classpath of your project.

Upvotes: 1

Related Questions