无法在eclipse中使用java访问hbase

wkftcu5l  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(362)

我是hadoop和hbase的新手,用javaapi在hbase中创建了创建表的小程序,但是遇到了大错误,解决不了。

这是我在eclipse ubuntu中运行的java程序

package trial;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HBaseAdmin;
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;

public class Sample {
    public static void main(String[] args) {
        try
        {
        System.out.println("Start working");
        Configuration conf=HBaseConfiguration.create();
        System.out.println("1");
//      conf.set("hbase.master","localhost:3569");
        System.out.println("2");
        HBaseAdmin admin=new HBaseAdmin(conf);
        System.out.println("3");
        HTableDescriptor td=new HTableDescriptor(TableName.valueOf("Employee"));
        System.out.println("4");
        td.addFamily(new HColumnDescriptor("Personal"));
        System.out.println("5");
        td.addFamily(new HColumnDescriptor("Professional"));
        System.out.println("6");
        admin.createTable(td);
        System.out.println("Table Created");

        admin.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();

        }

    }
}

这是错误的博客,我得到时,试图运行上述程序

Start working
1
2
log4j:WARN No appenders could be found for logger (org.apache.hadoop.security.Groups).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
3
4
5
6
org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=35, exceptions:
Tue Aug 29 00:26:32 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:26:32 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:26:32 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:26:32 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:26:33 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:26:34 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:26:36 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:26:40 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:26:50 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:27:00 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:27:10 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:27:20 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:27:40 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:28:00 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:28:20 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:28:41 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:29:01 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:29:21 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:29:41 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:30:01 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:30:21 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:30:41 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:31:01 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:31:21 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:31:42 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:32:02 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:32:22 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:32:42 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:33:02 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:33:22 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:33:42 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:34:02 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:34:22 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:34:42 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 00:35:02 IST 2017, RpcRetryingCaller{globalStartTime=1503946591438, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge

    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:159)
    at org.apache.hadoop.hbase.client.HBaseAdmin.executeCallable(HBaseAdmin.java:4389)
    at org.apache.hadoop.hbase.client.HBaseAdmin.executeCallable(HBaseAdmin.java:4381)
    at org.apache.hadoop.hbase.client.HBaseAdmin.createTableAsyncV2(HBaseAdmin.java:755)
    at org.apache.hadoop.hbase.client.HBaseAdmin.createTable(HBaseAdmin.java:676)
    at org.apache.hadoop.hbase.client.HBaseAdmin.createTable(HBaseAdmin.java:609)
    at trial.Sample.main(Sample.java:39)
Caused by: org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStub(ConnectionManager.java:1563)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(ConnectionManager.java:1583)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.getKeepAliveMasterService(ConnectionManager.java:1740)
    at org.apache.hadoop.hbase.client.MasterCallable.prepare(MasterCallable.java:38)
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:135)
    ... 6 more
Caused by: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callBlockingMethod(AbstractRpcClient.java:240)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient$BlockingRpcChannelImplementation.callBlockingMethod(AbstractRpcClient.java:336)
    at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$BlockingStub.isMasterRunning(MasterProtos.java:61347)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.isMasterRunning(ConnectionManager.java:1594)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStubNoRetries(ConnectionManager.java:1532)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStub(ConnectionManager.java:1554)
    ... 10 more
Caused by: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callBlockingMethod(AbstractRpcClient.java:225)
    ... 15 more
Caused by: java.lang.ClassNotFoundException: com.yammer.metrics.core.Gauge
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 16 more

另外,当我在终端上运行jps命令时,它会显示我的hmaster和hregionserver正在运行。我的hbase shell也运行得很好,但当我尝试运行该程序时,它会显示这一系列错误。请帮助我从过去的两天挣扎,但没有任何解决方案帮了我。提前谢谢

jecbmhm3

jecbmhm31#

由于存在一个修复程序,将此添加为答案而不仅仅是注解:
问题是您的yammer版本与hbase不兼容。尝试删除所有其他内容,只需要hbase本身。然后慢慢地一次添加一个库,直到失败(或者使用第三方的依赖性分析)。
还要确保yammer库包含在您的路径中。

相关问题