1

As the title goes.My source code is:

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)

It seems that this error has nothing to do with hbase server because I can use hbase shell properly. But I really don't konw how to fix this problem.Both from my Laptop(windows) Eclipse and a remote desktop(Ubuntu) linux Eclipse reports the same error.

Anyone can help me?

wuchang
  • 3,003
  • 8
  • 42
  • 66
  • I'm assuming `HBaseAdmin` and the classes it depends on reside in some jar. Is it possible the version of that jar you use in the build is not the same as the version of the jar you use in runtime? – Eran Jun 08 '14 at 12:06
  • Have you checked whether the version of HBase jar is compatible with your java version? When an error is thrown from 3rd party APIs, we can't do much, but to use a decompiler and see whats the cause at line number 337: (UserGroupInformation.java:337) – Dinal Jun 08 '14 at 12:08

3 Answers3

7

I was also facing the same problem but found the solution, This problem occurs due to jar issue since IBM_JAVA is constant

 public static final boolean IBM_JAVA = JAVA_VENDOR_NAME.contains("IBM");

and this constant is define in class org.apache.hadoop.util.PlatformName but this package structure and class is define in two jars:

  1. hadoop-core
  2. hadoop-auth

but the class present in hadoop-core does not have this constant.

IBM_JAVA

And your application trying to search in hadoop-core jar. So add hadoop-auth jar in your application.

Alok Pathak
  • 875
  • 1
  • 8
  • 20
  • 1
    If the problem persists after this, remove hadoop-core from your classpath. Since it is conflicting with hadoop-auth. – JayL Jul 29 '15 at 03:06
  • if the problem persists, remove hadoop-core from your classpath since it has the conflicting IBM_JAVA. – JayL Jul 29 '15 at 03:09
1

I have faced same problem when using earlier versions of jars for hadoop-core and hadoop-auth. Using below version jars resolves my problem.

hadoop-core-1.2.1.jar

hadoop-auth-2.2.0.jar

Manindar
  • 999
  • 2
  • 14
  • 30
Praveen
  • 21
  • 5
0

I had such problem, and removed the fs (filesystem) and security from the hadoop-common-X.X.X.jar. Then I added its compatible source code to my java source codes. Besides I removed hadoop-auth. because it was my first test, I removed them to get my code running.

e nahang
  • 3
  • 1
  • 7