在spark上执行配置单元查询 - java.lang.NoClassDefFoundError org / apache / hive / spark / client / Job

时间:2016-07-29 15:52:25

标签: hadoop apache-spark hive

我试图让Spark上的Hive正常工作,但似乎它没有加载hive-exec-2.0.1.jar。 我可以让Hive上先生完美地工作。 我使用Hive 2.0.1和Spark 1.6.1。跟着Hive on Spark教程。 我在hive-site.xml上设置了所有必需的属性,将spark程序集jar链接到hive lib文件夹,我已经设置了所有环境变量(SPARK_HOME等)。 我开始了Spark主人和工人。还启动了具有DEBUG级别的hiveserver2。试图运行一个简单的查询“select count(*)...”,就我在hive日志中看到的,它执行spark-submit命令包含所有nesscary参数,包括hive-exec-2.0.1.jar文件,但我仍然看到在执行期间我得到:

16/07/29 18:14:51 [RPC-Handler-3]: WARN rpc.RpcDispatcher: Received error message:io.netty.handler.codec.DecoderException: java.lang.NoClassDefFoundError: org/apache/hive/spark/client/Job
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:358)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:230)
    at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/apache/hive/spark/client/Job
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.hive.com.esotericsoftware.kryo.util.DefaultClassResolver.readName(DefaultClassResolver.java:154)
    at org.apache.hive.com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:133)
    at org.apache.hive.com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:670)
    at org.apache.hive.com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:118)
    at org.apache.hive.com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:551)
    at org.apache.hive.com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:790)
    at org.apache.hive.spark.client.rpc.KryoMessageCodec.decode(KryoMessageCodec.java:97)
    at io.netty.handler.codec.ByteToMessageCodec$1.decode(ByteToMessageCodec.java:42)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:327)
    ... 15 more
Caused by: java.lang.ClassNotFoundException: org.apache.hive.spark.client.Job
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 39 more
.
16/07/29 18:14:51 [RPC-Handler-3]: WARN client.SparkClientImpl: Client RPC channel closed unexpectedly.

你知道如何解决这个问题吗? 我尝试了一切:设置spark.jars属性,链接hive-exec-2.0.1.jar,设置spark.executor..property等。

它似乎应该没有任何问题,但由于某种原因,我无法让它工作......

还有别的吗?

3 个答案:

答案 0 :(得分:1)

当我在cloudera VM上设置spark时,我必须进行的更改以及将hive-site.xml复制到$SPARK_HOME/conf目录:

$SPARK_HOME/conf/classpath.txt文件中添加以下行:

/home/cloudera/spark-1.2.1-bin-hadoop2.4/lib/spark-1.2.1-yarn-shuffle.jar
/usr/jars/hive-exec-1.2.1.jar

$SPARK_HOME/conf/spark-default.conf文件中添加此属性(您已复制到hive lib的同一个程序集jar - 我不需要将程序集jar复制到hive lib。):

spark.yarn.jar=local:/home/cloudera/spark-1.2.1-bin-hadoop2.4/lib/spark-assembly-1.2.1-hadoop2.4.0.jar

同时检查classpath.txt文件中的hars版本的hive版本与你的版本相同,并且location(绝对路径)也是有效的。

答案 1 :(得分:0)

通过添加属性解决它:spark.driver.extraClassPath并指向:hive-exec-1.2.1.jar

答案 2 :(得分:0)

与旧版本的Hive 1.2及更新版本兼容的Spark版本是Spark 1.3.1。这是我设法使其成功的唯一一个,它已准备就绪。这不是基于任何供应商的版本。我在Hortonworks演讲中提出了这个问题。详情来自here

HTH,

密歇根