Support Questions

Find answers, ask questions, and share your expertise

My hadoop version in 2.8.0 on which hbase 1.2.6 is installed ..

New Contributor

i am running my java code to create a table

public static void main(String[] args) throws IOException
{
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "sandbox.hortonworks.com");
conf.set("hbase.zookeeper.property.clientPort", "2181");
conf.set("zookeeper.znode.parent", "/hbase-unsecure");
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf("people"));
tableDescriptor.addFamily(new HColumnDescriptor("personal"));
tableDescriptor.addFamily(new HColumnDescriptor("contactinfo"));
admin.createTable(tableDescriptor);
Put put = new Put(Bytes.toBytes("doe-john-m-12345"));
}

i build jar of code from maven eclipse and when running the jar in hadoop as:-

hadoop@localhost]$ hadoop jar htable-0.0.1-SNAPSHOT.jar pack.createtable

i am getting:--

java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/HBaseConfiguration
at pack.createtable.main(createtable.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:234)
at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.HBaseConfiguration
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more

3 REPLIES 3

Expert Contributor

Hello,

Ensure that when you submit your job you provide a jar with all the dependency included

The output of the following will show what jars are required to connect to HBase

$ hbase classpath

New Contributor

Hello, can you please clarify the steps to run the jar..i have set the path as :-

HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HBASE_HOME/lib/* and then running the jar