hbase java程序在maven eclipse中创建表构建错误

时间:2017-08-30 11:02:23

标签: java eclipse hadoop hbase apache-zookeeper

public class Class
{
     public static void main(String[] args) throws IOException 
     {
       Configuration config = HBaseConfiguration.create();  
       config.addResource(new Path("/usr/local/HBase/conf/hbase-site.xml"));
       config.addResource(new Path("/home/hadoop/hadoop/etc/hadoop/core-site.xml"));
       Connection connection = ConnectionFactory.createConnection(config);         
       Admin admin = connection.getAdmin();               
       HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf("people"));
       tableDescriptor.addFamily(new HColumnDescriptor("personal"));
       tableDescriptor.addFamily(new HColumnDescriptor("contactinfo"));
       admin.createTable(tableDescriptor);                   
   }

@localhost hadoop] $ hadoop jar hbase-0.0.1-SNAPSHOT-shaded.jar package.Class

错误: -

17/08/29 22:25:04 INFO client.RpcRetryingCaller: Call exception, tries=10,  retries=35, started=38496 ms ago, cancelled=false, msg=
17/08/29 22:25:14 INFO client.RpcRetryingCaller: Call exception, tries=11, retries=35, started=48538 ms ago, cancelled=false, msg=
17/08/29 22:25:35 INFO client.RpcRetryingCaller: Call exception, tries=12, retries=35, started=68728 ms ago, cancelled=false, msg=
17/08/29 22:25:55 INFO client.RpcRetryingCaller: Call exception, tries=13, retries=35, started=88917 ms ago, cancelled=false, msg=
17/08/29 22:26:15 INFO client.RpcRetryingCaller: Call exception, tries=14, retries=35, started=109077 ms ago, cancelled=false, msg=
17/08/29 22:26:35 INFO client.RpcRetryingCaller: Call exception, tries=15, retries=35, started=129269 ms ago, cancelled=false, msg=

Exception in thread "main" org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=35, exceptions:
Tue Aug 29 22:24:26 IST 2017, RpcRetryingCaller{globalStartTime=1504025666395, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 22:24:26 IST 2017, RpcRetryingCaller{globalStartTime=1504025666395, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 22:24:26 IST 2017, RpcRetryingCaller{globalStartTime=1504025666395, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 22:24:27 IST 2017, RpcRetryingCaller{globalStartTime=1504025666395, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge 
Tue Aug 29 22:24:27 IST 2017, RpcRetryingCaller{globalStartTime=1504025666395, pause=100, retries=35}, org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
Tue Aug 29 22:24:28 IST 2017, RpcRetryingCaller{globalStartTime=1504025666395, 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:157)
    at org.apache.hadoop.hbase.client.HBaseAdmin.executeCallable(HBaseAdmin.java:4297)
    at org.apache.hadoop.hbase.client.HBaseAdmin.executeCallable(HBaseAdmin.java:4289)
    at org.apache.hadoop.hbase.client.HBaseAdmin.createTableAsyncV2(HBaseAdmin.java:753)
    at org.apache.hadoop.hbase.client.HBaseAdmin.createTable(HBaseAdmin.java:674)
    at org.apache.hadoop.hbase.client.HBaseAdmin.createTable(HBaseAdmin.java:607)
    at puma.pack.main(pack.java:28)

 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:1561)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(ConnectionManager.java:1581)
    at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.getKeepAliveMasterService(ConnectionManager.java:1738)

 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:58383)

 Caused by: java.lang.NoClassDefFoundError: com/yammer/metrics/core/Gauge
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callBlockingMethod(AbstractRpcClient.java:225)
    ... 21 more

我已将hbase-client-jar,hbase-common-jar,metric-core-jar添加到我的eclipse POM文件中......我无法找到我要做的更改...请帮助我解决这个问题..

1 个答案:

答案 0 :(得分:0)

我解决了这个问题,因为出现了问题:java.lang.NoClassDefFoundError:com / yammer / metrics / core / Gauge 因此,将指标-core-2.2.0.jar添加到HADOOP_CLASSPATH不起作用...所以我将此jar添加到HADOOP mapred / lib,hdfs / lib,common / lib文件夹..这个jar在classpath中可用.. < / p>