Spark throws ClassNotFoundException when using --jars option

后端 未结 2 2031
抹茶落季
抹茶落季 2020-12-25 14:48

I was trying to follow the Spark standalone application example described here https://spark.apache.org/docs/latest/quick-start.html#standalone-applications

The exam

相关标签:
2条回答
  • 2020-12-25 15:19

    Is your SimpleApp class in any specific package? It seems that you need to include the full package name in the command line. So, if the SimpleApp class is located in com.yourcompany.yourpackage, you'd have to submit the Spark job with --class "com.yourcompany.yourpackage.SimpleApp" instead of --class "SimpleApp". I had the same problem and changing the name to the full package and class name fixed it. Hope that helps!

    0 讨论(0)
  • 2020-12-25 15:24

    According to spark-submit's --help, the --jars option expects a comma-separated list of local jars to include on the driver and executor classpaths.

    I think that what's happening here is that /home/linpengt/workspace/scala-learn/spark-analysis/target/pack/lib/* is expanding into a space-separated list of jars and the second JAR in the list is being treated as the application jar.

    One solution is to use your shell to build a comma-separated list of jars; here's a quick way of doing it in bash, based on this answer on StackOverflow (see that answer for more complex approaches that handle filenames that contain spaces):

    spark-submit --jars $(echo /dir/of/jars/*.jar | tr ' ' ',') \
        --class "SimpleApp" --master local[4] path/to/myApp.jar
    
    0 讨论(0)
提交回复
热议问题