添加aws jar时火花壳抛出错误

时间:2019-07-13 18:43:40

标签: amazon-web-services apache-spark

我在Windows机器上安装了spark 2.4.3。 spark-shell工作正常。

我正在编写代码以从AWS S3存储桶读取文件。我从maven放下了hadoop-aws-3.2.0.jar并放置在C:\ spark_2.4.3 \ jars中。

在命令外壳中,我尝试通过以下命令。

spark-shell --jars hadoop-aws-3.2.0.jar

但是它抛出了异常。

        19/07/14 00:11:39 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    19/07/14 00:11:39 WARN FileSystem: Cannot load filesystem
    java.util.ServiceConfigurationError: org.apache.hadoop.fs.FileSystem: Provider org.apache.hadoop.fs.s3a.S3AFileSystem could not be instantiated
            at java.util.ServiceLoader.fail(ServiceLoader.java:232)
            at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
            at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
            at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
            at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
            at org.apache.hadoop.fs.FileSystem.loadFileSystems(FileSystem.java:2631)
            at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2650)
            at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667)
            at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:94)
            at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2703)
            at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2685)
            at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:373)
            at org.apache.spark.deploy.DependencyUtils$.org$apache$spark$deploy$DependencyUtils$$resolveGlobPath(DependencyUtils.scala:191)
            at org.apache.spark.deploy.DependencyUtils$$anonfun$resolveGlobPaths$2.apply(DependencyUtils.scala:147)
            at org.apache.spark.deploy.DependencyUtils$$anonfun$resolveGlobPaths$2.apply(DependencyUtils.scala:145)
            at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
            at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
            at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
            at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:35)
            at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:241)
            at scala.collection.AbstractTraversable.flatMap(Traversable.scala:104)
            at org.apache.spark.deploy.DependencyUtils$.resolveGlobPaths(DependencyUtils.scala:145)
            at org.apache.spark.deploy.SparkSubmit$$anonfun$prepareSubmitEnvironment$3.apply(SparkSubmit.scala:354)
            at org.apache.spark.deploy.SparkSubmit$$anonfun$prepareSubmitEnvironment$3.apply(SparkSubmit.scala:354)
            at scala.Option.map(Option.scala:146)
            at org.apache.spark.deploy.SparkSubmit.prepareSubmitEnvironment(SparkSubmit.scala:354)
            at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:143)
            at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:86)
            at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:924)
            at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:933)
            at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
    Caused by: java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentialsProvider
            at java.lang.Class.getDeclaredConstructors0(Native Method)
            at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
            at java.lang.Class.getConstructor0(Class.java:3075)
            at java.lang.Class.newInstance(Class.java:412)
            at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
            ... 28 more
    Caused by: java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentialsProvider
            at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
            ... 33 more

解决上述问题的方法是什么。感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我将查阅Troubleshooting S3A文档,然后查看类路径