Support Questions

Find answers, ask questions, and share your expertise

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/HBaseConfiguration

avatar
Expert Contributor

hadoop jar /root/hbase.jar MyfirstHBaseTable WARNING: Use "yarn jar" to launch YARN applications. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/HBaseConfiguration at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:278) at org.apache.hadoop.util.RunJar.run(RunJar.java:214) at org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.HBaseConfiguration at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 4 more

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;publicclassMyfirstHBaseTable{publicstaticvoid main(String[] args)throwsIOException{HBaseConfiguration hconfig =newHBaseConfiguration(newConfiguration());HTableDescriptor htable =newHTableDescriptor("User"); 
    htable.addFamily(newHColumnDescriptor("Id"));
    htable.addFamily(newHColumnDescriptor("Name"));System.out.println("Connecting...");HBaseAdmin hbase_admin =newHBaseAdmin( hconfig );System.out.println("Creating Table...");
    hbase_admin.createTable( htable );System.out.println("Done!");}}
4 REPLIES 4

avatar
Master Mentor

@sivasaravanakumar k

you need to include hbase-client and hadoop-client in your dependencies. What version of HBase and Hadoop are you using?

avatar
Expert Contributor

HDP 2.3.0

hadoop 2.7.1

Hbase 1.1.1

i already include below dependencies jar

/usr/hdp/2.3.0.0-2557/hbase/lib/


1.png5.png3.png
2.png4.png

avatar
Master Mentor

@sivasaravanakumar k I don't see hadoop included. Why not use maven instead of including each jar manually? Take a look at my example https://github.com/dbist/HBaseNewApi.git specifically pom.xml that's all you need.

avatar
New Contributor

I have got similar problem.

hadoop jar HBaseBulkLoader.jar HBaseBulkLoadDriver ../flume/data/MY_SCHEMA.TAB_BL_10C op1 WARNING: Use "yarn jar" to launch YARN applications. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/HBaseConfiguration at HBaseBulkLoadDriver.main(HBaseBulkLoadDriver.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.util.RunJar.run(RunJar.java:221) at org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.HBaseConfiguration at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

It says HBaseConfiguration.class not found. I have tried by setting the following environmental variables also.

# echo $LIBJARS

/usr/hdp/2.4.0.0-169/hadoop/lib/*.jar,/usr/hdp/2.4.0.0-169/hbase/lib/*.jar
#  echo $HADOOP_TASKTRACKER_OPTS/usr/hdp/2.4.0.0-169/hadoop/lib:/usr/hdp/2.4.0.0-169/hbase/lib
# echo $HADOOP_CLASSPATH

/usr/hdp/2.4.0.0-169/hadoop/lib:/usr/hdp/2.4.0.0-169/hbase/lib
# echo $CLASSPATH

/usr/hdp/2.4.0.0-169/flume/lib:/usr/hdp/2.4.0.0-169/hbase/lib

I have tried the following also.

hadoop jar HBaseBulkLoader.jar HBaseBulkLoadDriver -D mapred.chold.env="/usr/hdp/2.4.0.0-169/hbase/lib/" ../flume/data/MY_SCHEMA.TAB_BL_10C op1
hadoop jar HBaseBulkLoader.jar HBaseBulkLoadDriver -libjars /usr/hdp/2.4.0.0-169/hbase/lib/hbase-common.jar ../flume/data/MY_SCHEMA.TAB_BL_10C op1.txt

Its all the same error. Can anybody help what is wrong with my approach?