2017-05-22 76 views
1

當我嘗試在配置單元使用spark時查詢配置單元中的表時遇到錯誤。例如,當我這樣做:Hive錯誤:線程「main」中的異常java.lang.NoClassDefFoundError:scala/collection/Iterable

select count(*) from ma_table; 

我得到這個:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/Iterable 
    at org.apache.hadoop.hive.ql.parse.spark.GenSparkProcContext.<init>(GenSparkProcContext.java:163) 
    at org.apache.hadoop.hive.ql.parse.spark.SparkCompiler.generateTaskTree(SparkCompiler.java:195) 
    at org.apache.hadoop.hive.ql.parse.TaskCompiler.compile(TaskCompiler.java:267) 
    at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:10947) 
    at org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:246) 
    at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:250) 
    at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:477) 
    at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1242) 
    at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1384) 
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1171) 
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1161) 
    at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:232) 
    at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:183) 
    at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:399) 
    at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:776) 
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:714) 
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:641) 
    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:234) 
    at org.apache.hadoop.util.RunJar.main(RunJar.java:148) 
Caused by: java.lang.ClassNotFoundException: scala.collection.Iterable 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 23 more 

經過一番研究,我想是這樣我的.bashrc(和採購它;)):

for f in ${HIVE_LIB}/*.jar; do 
    CLASSPATH=${CLASSPATH}:$f; 
done 


for f in ${SPARK_HOME}/jars/*.jar; do 
    CLASSPATH=${CLASSPATH}:$f; 
done 


for f in ${SCALA_HOME}/lib/*.jar; do 
    CLASSPATH=${CLASSPATH}:$f; 
done 

我檢查過,並且CLASSPATH中的所有這些罐子仍然出現錯誤。 我使用的是Hive 2.1,Hadoop 2.8和Spark 2.1。 任何想法?提前致謝!

回答

相關問題