scala Spark:有没有办法打印出 spark-shell 和 spark 的类路径?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30512598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 07:11:49  来源:igfitidea点击:

Spark: is there a way to print out classpath of both spark-shell and spark?

scalaapache-spark

提问by catrapture

I can run a spark job successfully in the spark-shell but when its packages and run through spark-submit Im getting a NoSuchMethodError.

我可以在 spark-shell 中成功运行一个 spark 作业,但是当它的包并通过 spark-submit 运行时,我得到了一个 NoSuchMethodError。

This indicates to me some sort of mismatch of classpaths. Is there a way I can compare the two classpaths? Some sort of logging statement?

这向我表明了类路径的某种不匹配。有没有办法比较这两个类路径?某种日志语句?

Thanks!

谢谢!

15/05/28 12:46:46 ERROR Executor: Exception in task 1.0 in stage 0.0 (TID 1)
java.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;
    at com.ldamodel.LdaModel$$anonfun$$anonfun$apply.apply(LdaModel.scala:22)
    at com.ldamodel.LdaModel$$anonfun$$anonfun$apply.apply(LdaModel.scala:22)
    at scala.collection.TraversableLike$$anonfun$map.apply(TraversableLike.scala:244)
    at scala.collection.TraversableLike$$anonfun$map.apply(TraversableLike.scala:244)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
    at scala.collection.AbstractTraversable.map(Traversable.scala:105)
    at com.ldamodel.LdaModel$$anonfun.apply(LdaModel.scala:22)
    at com.ldamodel.LdaModel$$anonfun.apply(LdaModel.scala:22)
    at scala.collection.Iterator$$anon.hasNext(Iterator.scala:371)
    at org.apache.spark.util.collection.ExternalSorter.insertAll(ExternalSorter.scala:202)
    at org.apache.spark.shuffle.sort.SortShuffleWriter.write(SortShuffleWriter.scala:56)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:68)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41)
    at org.apache.spark.scheduler.Task.run(Task.scala:64)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:203)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

回答by Justin Pihony

I think this should work:

我认为这应该有效

    import java.lang.ClassLoader
    val cl = ClassLoader.getSystemClassLoader
    cl.asInstanceOf[java.net.URLClassLoader].getURLs.foreach(println)

回答by Daniel Zolnai

Without modifying the code:

不修改代码:

SPARK_PRINT_LAUNCH_COMMAND=true /usr/lib/spark/bin/spark-shell

Also works with spark-submit.

也适用于spark-submit.

回答by NoUserException

This should do the trick without requiring any code changes:

这应该不需要任何代码更改即可解决问题:

--conf 'spark.driver.extraJavaOptions=-verbose:class'
--conf 'spark.executor.extraJavaOptions=-verbose:class'

回答by stackexchanger

/opt/spark/bin/compute-classpath.sh