hi, everyone. I wrote HBase java program as follows:
public class Test {
private String tableName = "ImageFeatures";
private HTable table = null;
private HBaseConfiguration conf = new HBaseConfiguration();
public void createTable() throws IOException {
HBaseAdmin admin = new HBaseAdmin(conf);
if (!admin.tableExists(tableName)) {
System.out.println("creating table...");
HTableDescriptor tableDescripter = new
HTableDescriptor(tableName.getBytes());
tableDescripter.addFamily(new HColumnDescriptor("ID"));
tableDescripter.addFamily(new HColumnDescriptor("Path"));
tableDescripter.addFamily(new HColumnDescriptor("Features"));
admin.createTable(tableDescripter);
System.out.println("creat table successfully!");
}
}
public static void main(String args[]) throws IOException {
Test test = new Test();
test.createTable();
}
}
There is some error when I run ./hadoop jar test.jar, seems cann't connect to
the server
09/10/20 11:24:26 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 0 time(s).
09/10/20 11:24:27 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 1 time(s).
09/10/20 11:24:28 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 2 time(s).
09/10/20 11:24:29 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 3 time(s).
09/10/20 11:24:30 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 4 time(s).
09/10/20 11:24:31 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 5 time(s).
09/10/20 11:24:32 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 6 time(s).
09/10/20 11:24:33 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 7 time(s).
09/10/20 11:24:34 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 8 time(s).
09/10/20 11:24:35 INFO ipc.Client: Retrying connect to server:
localhost/127.0.0.1:60000. Already tried 9 time(s).
09/10/20 11:24:35 INFO client.HConnectionManager$TableServers: Attempt 0 of 10
failed with <java.net.ConnectException: Call to localhost/127.0.0.1:60000
failed on connection exception: java.net.ConnectException: Connection refused>.
Retrying after sleep of 2000
Exception in thread "main" java.lang.IllegalAccessError: tried to access method
org.apache.hadoop.ipc.Client.incCount()V from class
org.apache.hadoop.ipc.HBaseClient
at org.apache.hadoop.ipc.HBaseClient.incCount(HBaseClient.java:48)
at
org.apache.hadoop.hbase.ipc.HbaseRPC$ClientCache.getClient(HbaseRPC.java:187)
at
org.apache.hadoop.hbase.ipc.HbaseRPC$ClientCache.access$200(HbaseRPC.java:164)
at
org.apache.hadoop.hbase.ipc.HbaseRPC$Invoker.<init>(HbaseRPC.java:238)
at org.apache.hadoop.hbase.ipc.HbaseRPC.getProxy(HbaseRPC.java:384)
at org.apache.hadoop.hbase.ipc.HbaseRPC.getProxy(HbaseRPC.java:364)
at org.apache.hadoop.hbase.ipc.HbaseRPC.getProxy(HbaseRPC.java:412)
at
org.apache.hadoop.hbase.client.HConnectionManager$TableServers.getMaster(HConnectionManager.java:188)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:67)
at Test.createTable(Test.java:24)
at Test.main(Test.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
I am confused why it connect localhost:60000, may my hbase configuration be
right? Would someone can help me solve this problem? Thanks!
Best Wishes!
_____________________________________________________________
刘祥龙 Liu Xianglong
北京航空航天大学软件开发环境国家重点实验室(新主楼G611室) NLSDE, Beihang Univ.
Tel:(+86)10-8233 8094
E-Mail: [email protected]