【问题标题】:java.lang.NoClassDefFoundError with HBase Scan带有 HBase 扫描的 java.lang.NoClassDefFoundError
【发布时间】:2013-10-24 22:12:05
【问题描述】:

我正在尝试运行 MapReduce 作业来扫描 HBase 表。目前我正在使用 Cloudera 4.4 附带的 HBase 0.94.6 版本。在我的程序中的某个时刻,我使用 Scan(),并正确导入它:

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

它编译得很好,我也可以创建一个 jar 文件。我通过传递 hbase classpath 作为 -cp 选项的值来做到这一点。运行程序时,我收到以下消息:

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

我使用以下代码运行代码:

hadoop jar my_program.jar MyJobClass -libjars <list_of_jars>

其中 list_of_jars 包含 /opt/cloudera/parcels/CDH/lib/hbase/hbase.jar。只是为了仔细检查,我确认 hbase.jar 包含 Scan。我这样做:

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

我可以看到这条线:

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

在输出中。在我看来一切都很好。我不明白为什么说 Scan 没有定义。我传递了正确的 jar,它包含类。

感谢任何帮助。

【问题讨论】:

    标签: java hadoop jar hbase


    【解决方案1】:

    设置 HADOOP_CLASSPATH 变量解决了这个问题:

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

    【讨论】:

    • 我需要在哪个文件中设置上面说的classpath?
    • 更改 ~/.bash_profile export HADOOP_CLASSPATH=depend_on_you_machine/bin/hbase 类路径
    • 在 linux 中?我们需要在 bashrc 或 hbase-env.sh 文件中添加这个吗?
    猜你喜欢
    • 2014-04-27
    • 2015-07-16
    • 2012-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多