Spark提交:使用jar

时间:2017-07-26 05:14:28

标签: java hadoop apache-spark apache-spark-sql spark-submit

当我从intellij ide运行HiveRead.java时,我可以成功运行并获得结果。然后我创建了jar文件(它是一个maven项目),然后我尝试从IDE运行,它给了我

ClassLoaderResolver for class "" gave error on creation : {1}

然后我查看了SO答案,发现我必须添加datanulcues罐子,我做了类似的事情

java -jar /home/saurab/sparkProjects/spark_hive/target/myJar-jar-with-dependencies.jar --jars jars/datanucleus-api-jdo-3.2.6.jar,jars/datanucleus-core-3.2.10.jar,jars/datanucleus-rdbms-3.2.9.jar,/home/saurab/hadoopec/hive/lib/mysql-connector-java-5.1.38.jar

然后我收到了这个错误

org.datanucleus.exceptions.NucleusUserException: Persistence process has been specified to use a ClassLoaderResolver of name "datanucleus" yet this has not been found by the DataNucleus plugin mechanism. Please check your CLASSPATH and plugin specification.

某处我发现我应该spark-submit。所以我确实喜欢这个

./bin/spark-submit --class HiveRead --master yarn  --jars jars/datanucleus-api-jdo-3.2.6.jar,jars/datanucleus-core-3.2.10.jar,jars/datanucleus-rdbms-3.2.9.jar,/home/saurab/hadoopec/hive/lib/mysql-connector-java-5.1.38.jar --files /home/saurab/hadoopec/spark/conf/hive-site.xml /home/saurab/sparkProjects/spark_hive/target/myJar-jar-with-dependencies.jar

现在我遇到了新的错误

Table or view not found: `bigmart`.`o_sales`; 

帮助我!! :)

我已将hive-site.xml复制到/spark/conf,启动了hive-Metoreore服务(hiveserver2 --service metastore

如果有人有兴趣,这里是HiveRead.Java code

1 个答案:

答案 0 :(得分:0)

Spark会话无法读取配置单元目录。

使用以下spark-submit命令提供hive-site.xml文件路径。

对于hortonworks-文件路径/usr/hdp/current/spark2-client/conf/hive-site.xml

在spark-submit命令中将其作为--files /usr/hdp/current/spark2-client/conf/hive-site.xml传递。