spark-shell 中的 HBase SparkContext 类型不匹配

问题描述

我正在尝试在 spark-shell 中使用 HBase。有两个集群:Cloudera 和 Hortonwork。 Cloudera 集群执行完美的命令,而 Hortonwork one 以相同的命令失败并出现奇怪的错误

scala> new HBaseContext(sc,conf)
<console>:30: error: type mismatch;
 found   : org.apache.spark.org.apache.spark.org.apache.spark.org.apache.spark.org.apache.spark.SparkContext
 required: org.apache.spark.org.apache.spark.org.apache.spark.org.apache.spark.org.apache.spark.SparkContext
Error occurred in an application involving default arguments.
        new HBaseContext(sc,conf)
                         ^

以下是 spark-shell 在 HDP 上的更详细输出

scala> import org.apach.hadoop.hbase.HBaseConfiguration
import org.apach.hadoop.hbase.HBaseConfiguration
warning: Class org.apache.yetus.audience.InterfaceAudience not found - continuing with a stub

scala> import org.apache.hadoop.hbase.spark.HBaseContext
org.apache.hadoop.hbase.spark.HBaseContext
warning: Class org.apache.yetus.audience.InterfaceAudience not found - continuing with a stub
error: missing or invalid dependency detected while loading class file 'HBaseContext.class'.
Could not access term yetus in  package org.apache,because it (or its dependencies) are missing. Check your build deFinition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'HBaseContext.class' was compiled against an incompatible version of org.apache.
error: missing or invalid dependency detected while loading class file 'HBaseContext.class'.
Could not access term audience in value org.apache.yetus,because it (or its dependencies) are missing. Check your build deFinition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'HBaseContext.class' was compiled against an incompatible version of org.apache.yetus.

scala> val conf = HBaseConfiguration.create()
conf: org.apache.hadoop.conf.Configuration = Configuration: core-default.xml,core-site.xml,mapred-default.xml,mapred-site.xml,yarn-default.xml,yarn-site.xml,hdfs-default.xml,hdfs-site.xml,hbase-defaul.xml,hbase-site.xml

scala> conf.addResource(new Path("/etc/hbase/3.0.1.0-187/0/hbase-site.xml")

scala> new HBaseContext(sc,conf)
                         ^

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)