正如标题所说。我的源代码是:
package hbase;
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.client.HBaseAdmin;
import org.apache.hadoop.hbase.util.Bytes;
public class HbaseExampleClient {
public static void main(String[] args) throws IOException {
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "192.168.10.17");
config.set("hbase.zookeeper.property.clientPort", "2222");
HBaseAdmin admin = new HBaseAdmin(config);//reports an IBM_JAVA NoSuchFieldError
HTableDescriptor htd = new HTableDescriptor("test1111");
HColumnDescriptor hcd = new HColumnDescriptor("data");
htd.addFamily(hcd);
admin.createTable(htd);
byte[] tablename = htd.getName();
HTableDescriptor[] tables = admin.listTables();
if(tables.length!= 1 && Bytes.equals(tablename, tables[0].getName()))
{
throw new IOException("Failed create of table!");
}
admin.close();
}
}
Exception in thread "main" java.lang.NoSuchFieldError: IBM_JAVA
at org.apache.hadoop.security.UserGroupInformation.getOSLoginModuleName(UserGroupInformation.java:337)
at org.apache.hadoop.security.UserGroupInformation.<clinit>(UserGroupInformation.java:382)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.hadoop.hbase.util.Methods.call(Methods.java:37)
at org.apache.hadoop.hbase.security.User.call(User.java:624)
at org.apache.hadoop.hbase.security.User.callStatic(User.java:614)
at org.apache.hadoop.hbase.security.User.access$300(User.java:52)
at org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:431)
at org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:426)
at org.apache.hadoop.hbase.security.User.getCurrent(User.java:177)
at org.apache.hadoop.hbase.client.UserProvider.getCurrent(UserProvider.java:78)
at org.apache.hadoop.hbase.client.UserProvider.getCurrentUserName(UserProvider.java:62)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionKey.<init>(HConnectionManager.java:473)
at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:198)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:116)
at hbase.HbaseExampleClient.main(HbaseExampleClient.java:19)
这个错误似乎与hbase server无关,因为我可以正确使用hbase shell。但我真的不知道如何解决这个问题。我的笔记本电脑(windows)Eclipse 和远程桌面(Ubuntu)linux Eclipse 都报告了同样的错误。
任何人都可以帮助我吗?