简体   繁体   中英

Error while creating table through java api in HBase

I am trying to create a table in HBase through JAVA api. My code is as follows:

Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "127.0.0.1");
config.set("hbase.client.retries.number", "1");
config.set("zookeeper.session.timeout", "40000");
config.set("zookeeper.recovery.retry", "1");

System.out.println("HBASE is running");
Connection conn = ConnectionFactory.createConnection(config);
Table table = conn.getTable(TableName.valueOf("recommendations"));
HTableDescriptor tableDescriptor = table.getTableDescriptor();
tableDescriptor.addFamily(new HColumnDescriptor("personal"));
tableDescriptor.addFamily(new HColumnDescriptor("professional"));
Admin admin = conn.getAdmin();
// Execute the table through admin
admin.createTable(tableDescriptor);

The error is as below:

Caused by:

org.apache.hadoop.hbase.MasterNotRunningException:
  com.google.protobuf.ServiceException:
  org.apache.hadoop.hbase.DoNotRetryIOException:
  java.lang.NoSuchMethodError: org.apache.hadoop.net.NetUtils.getInputStream(Ljava/net/Socket;)Lorg/apache/hadoop/net/SocketInputWrapper;
at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStub(ConnectionManager.java:1485)
at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(ConnectionManager.java:1505)
at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.getKeepAliveMasterService(ConnectionManager.java:1711)
at org.apache.hadoop.hbase.client.MasterCallable.prepare(MasterCallable.java:38)
at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:124)

I am able to create a table through the hbase shell. Any input will be appreciated.

It seems HBase in ConnectionManager is trying to use the method SocketInputWrapper NetUtils#getInputStream(Socket) from Hadoop, but such method is not found.

So: the class exists, but does not have that method.

Much probably you are using some classes of HBase for Hadoop 1 and using it with Hadoop 2, or viceversa, or some uncompatible versions.

What versions of Hadoop and HBase are you using? What versions of Hadoop and HBase are using HBase shell?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM