简体   繁体   中英

java.lang.NoClassDefFoundError with HBase Scan

I am trying to run a MapReduce job to scan a HBase table. Currently I am using the version 0.94.6 of HBase that comes with Cloudera 4.4. At some point in my program I use Scan(), and I properly import it with:

import org.apache.hadoop.hbase.client.Scan;

It compiles well and I am able to create a jar file too. I do it by passing the hbase classpath as the value for the -cp option. When running the program, I obtain the following message:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/client/Scan

I run the code using:

hadoop jar my_program.jar MyJobClass -libjars <list_of_jars>

where list_of_jars contains /opt/cloudera/parcels/CDH/lib/hbase/hbase.jar. Just to double-check, I confirmed that hbase.jar contains Scan. I do it with:

jar tf /opt/cloudera/parcels/CDH/lib/hbase/hbase.jar

And I can see the line:

org/apache/hadoop/hbase/client/Scan.class

in the output. All looks ok to me. I don't understand why is saying that Scan is not defined. I pass the correct jar, and it contains the class.

Any help is appreciated.

设置HADOOP_CLASSPATH变量修复了问题:

export HADOOP_CLASSPATH=`/usr/bin/hbase classpath`

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