简体   繁体   中英

HBase on Tomcat7 setup error: Could not initialize class org.apache.hadoop.security.ShellBasedUnixGroupsMapping

I am trying to access HBase on AWS EMR master node through a tomcat servlet.

I have this code on a tomcat servlet get request:

        Configuration conf = HBaseConfiguration.create();
        conf.setInt("timeout", 120000);
        conf.set("hbase.master", "*" + hbaseHost + ":9000*");
        conf.set(HBASE_CONFIGURATION_ZOOKEEPER_QUORUM, hbaseZookeeperQuorum);
        conf.set(HBASE_CONFIGURATION_ZOOKEEPER_CLIENTPORT, hbaseZookeeperClientPort);
        @SuppressWarnings("resource")
        HTable table = new HTable(conf, "ReTweet");

When I run this I get the following stack trace:

    java.lang.NoClassDefFoundError: Could not initialize class org.apache.hadoop.security.ShellBasedUnixGroupsMapping
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:270)
org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:861)
org.apache.hadoop.conf.Configuration.getClass(Configuration.java:906)
org.apache.hadoop.conf.Configuration.getClass(Configuration.java:932)
org.apache.hadoop.security.Groups.<init>(Groups.java:48)
org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:140)
org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:205)
org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:184)
org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:236)
org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:477)
org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:463)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
org.apache.hadoop.hbase.util.Methods.call(Methods.java:37)
org.apache.hadoop.hbase.security.User.call(User.java:586)
org.apache.hadoop.hbase.security.User.callStatic(User.java:576)
org.apache.hadoop.hbase.security.User.access$400(User.java:50)
org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:393)
org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:388)
org.apache.hadoop.hbase.security.User.getCurrent(User.java:139)
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionKey.<init>(HConnectionManager.java:412)
org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:182)
org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:98)
project.Query.doGet(Query.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

I have the following files in WEB-INF/lib folder:

hadoop-core.jar
commons-configuration-1.6.jar
commons-logging-api-1.1.1.jar
commons-cli-1.2.jar
hbase.jar
zookeeper-3.4.3.jar
hbase-site.xml
core-site.xml

I have no idea how to fix this. Is this an issue related to my hbase configuration or another problem? Do I need to include other jars in the lib directory?

The problem was missing jar files. We have those files and its working:

-rw-r--r-- 1 hadoop hadoop 298829 Nov 25 17:42 commons-configuration-1.6.jar

-rw-r--r-- 1 hadoop hadoop 279193 Nov 25 17:42 commons-lang-2.5.jar

-rw-r--r-- 1 hadoop hadoop 60686 Nov 25 17:42 commons-logging-1.1.1.jar

-rw-r--r-- 1 hadoop hadoop 432 Nov 25 17:42 core-site.xml

-rw-r--r-- 1 hadoop hadoop 4203147 Nov 25 17:42 hadoop-core-1.2.1.jar

-rw-r--r-- 1 hadoop hadoop 5286227 Nov 25 17:42 hbase-0.94.13.jar

-rw-r--r-- 1 hadoop hadoop 2581658 Nov 25 17:42 hbase-0.94.13-tests.jar

-rw-r--r-- 1 hadoop hadoop 2250 Nov 25 17:42 hbase-policy.xml

-rw-r--r-- 1 hadoop hadoop 1932 Nov 25 17:42 hbase-site.xml

-rw-r--r-- 1 hadoop hadoop 254 Nov 25 17:42 hdfs-site.xml

-rw-r--r-- 1 hadoop hadoop 481535 Nov 25 17:42 log4j-1.2.16.jar

-rw-r--r-- 1 hadoop hadoop 449818 Nov 25 17:45 protobuf-java-2.4.0a.jar

-rw-r--r-- 1 hadoop hadoop 15345 Nov 25 17:42 slf4j-api-1.4.3.jar

-rw-r--r-- 1 hadoop hadoop 8601 Nov 25 17:42 slf4j-log4j12-1.4.3.jar

-rw-r--r-- 1 hadoop hadoop 779974 Nov 25 17:42 zookeeper-3.4.5.jar

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