Hadoop Jar 运行HBase类的报错,解决方法

问题如下:

[root@qf01 ~]# hadoop jar testHBase-1.0-SNAPSHOT.jar com.qf.hbase.hbasewordcount.HBaseWordCountApp /tmp/hbase-root/hbase/data/default/wordcount /outdata/hbasewordcount
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/mapreduce/TableInputFormat
        at com.qf.hbase.hbasewordcount.HBaseWordCountApp.main(HBaseWordCountApp.java:31)
        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:221)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.mapreduce.TableInputFormat
        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

解决方法如下:

修改Hadoop的hadoop-env.xml,添加如下代码,注意:请修改为自己HBase的类路径

export HADOOP_CLASSPATH=$HBASE_HOME/lib/*

 

你可能感兴趣的:(HBase)