尝试使用Scala + Spark构建自包含应用程序时,未解决的依赖项错误

时间:2015-06-26 13:56:05

标签: scala apache-spark sbt

我正在尝试关注Self-Contained Applications Tutorial并尝试使用sbtscala进行构建,但在从sbt package调用C:\Users\00926133\test时遇到以下错误}:

[info] Set current project to Simple Project (in build file:/C:/Users/00926133/test/)
[info] Updating {file:/C:/Users/00926133/test/}test...
[info] Resolving org.scala-lang#scala-library;2.10.4 ...
[info] Resolving org.scala-lang#scala-library;2.10.4 ...
[error] Unable to find credentials for [ @ XXXX].
[info] Resolving org.apache.spark#spark-core_2.10;1.4.0 ...
[info] Resolving org.apache.spark#spark-core_2.10;1.4.0 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.4 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scala-lang#scala-library;2.10.4: java.util.NoSuchElementException
[warn]  :: org.apache.spark#spark-core_2.10;1.4.0: java.util.NoSuchElementException
[warn]  :: org.scala-lang#scala-compiler;2.10.4: java.util.NoSuchElementException
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Unresolved dependencies path:
[warn]      org.scala-lang:scala-library:2.10.4 ((sbt.Classpaths) Defaults.scala#L1203)
[warn]        +- simple-project:simple-project_2.10:1.0
[warn]      org.apache.spark:spark-core_2.10:1.4.0 (C:\Users\00926133\test\simple.sbt#L7-8)
[warn]        +- simple-project:simple-project_2.10:1.0
[warn]      org.scala-lang:scala-compiler:2.10.4
[warn]        +- simple-project:simple-project_2.10:1.0
sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.4: java.util.NoSuchElementException
unresolved dependency: org.apache.spark#spark-core_2.10;1.4.0: java.util.NoSuchElementException
unresolved dependency: org.scala-lang#scala-compiler;2.10.4: java.util.NoSuchElementException
    at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:291)
    at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:188)
    at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:165)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
    at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:132)
    at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
    at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
    at xsbt.boot.Using$.withResource(Using.scala:10)
    at xsbt.boot.Using$.apply(Using.scala:9)
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
    at xsbt.boot.Locks$.apply0(Locks.scala:31)
    at xsbt.boot.Locks$.apply(Locks.scala:28)
    at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
    at sbt.IvySbt.withIvy(Ivy.scala:127)
    at sbt.IvySbt.withIvy(Ivy.scala:124)
    at sbt.IvySbt$Module.withModule(Ivy.scala:155)
    at sbt.IvyActions$.updateEither(IvyActions.scala:165)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1369)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1365)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$87.apply(Defaults.scala:1399)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$87.apply(Defaults.scala:1397)
    at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1402)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1396)
    at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
    at sbt.Classpaths$.cachedUpdate(Defaults.scala:1419)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1348)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1310)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.4: java.util.NoSuchElementException
[error] unresolved dependency: org.apache.spark#spark-core_2.10;1.4.0: java.util.NoSuchElementException
[error] unresolved dependency: org.scala-lang#scala-compiler;2.10.4: java.util.NoSuchElementException
[error] Total time: 1 s, completed Jun 26, 2015 9:13:40 AM

我成功运行了spark-shellscala,以及pythonR的火花示例。我也尝试删除.ivy文件夹。

<小时/> 我的simple.sbt文件:

name := "Simple Project"

version := "1.0"

scalaVersion := "2.10.4"

libraryDependencies += "org.apache.spark" % "spark-core_2.10" % "1.4.0"

其他信息

  • scala -version == 2.10.4
  • sbt sbt-version == 0.13.8
  • 我的simple.sbt文件位于C:\Users\00926133\test
  • SimpleApp.scala位于C:\Users\00926133\test\src\main\scala
  • Spark居住在C:\Users\00926133\spark-1.4.0-bin-hadoop2.6

我查看了几个Stack Overflow帖子,但是那里显示的解决方案似乎没有给我任何牵引力。

<小时/>

更新
我能够确认这是代理相关的问题。但是,我仍然无法在我的代理后面构建。这是在Windows上,我有以下内容:

环境变量

SBT_OPTS = -Dhttp.proxyHost=<myhost> -Dhttp.proxyPort=<myport> -Dhttp.proxyUser=<myuser> -Dhttp.proxyPassword=<mypassword> -Dhttps.proxyHost=<myhost> -Dhttps.proxyPort=<myport> -Dhttps.proxyUser=<myuser> -Dhttps.proxyPassword=<mypassword> 
JAVA_OPTS = -Dhttp.proxyHost=<myhost> -Dhttp.proxyPort=<myport> -Dhttp.proxyUser=<myuser> -Dhttp.proxyPassword=<mypassword> -Dhttps.proxyHost=<myhost> -Dhttps.proxyPort=<myport> -Dhttps.proxyUser=<myuser> -Dhttps.proxyPassword=<mypassword>

我还将以下行添加到位于sbtconfig.txt下的..\sbt\conf

-Dhttp.proxyHost=<myhost>
-Dhttp.proxyPort=<myport>
-Dhttp.proxyUser=<myuser>
-Dhttp.proxyPassword=<mypassword>
-Dhttps.proxyHost=<myhost>
-Dhttps.proxyPort=<myport>
-Dhttps.proxyUser=<myuser>
-Dhttps.proxyPassword=<mypassword>

任何能够(a)以外行人的方式解释sbt package正在做什么,(b)如何解释simple.sbt文件,和/或( c)弄清楚如何解决[error] Unable to find credentials for [ @ XXXX ] - XXXX是我工作的代理服务器。

1 个答案:

答案 0 :(得分:3)

我在SBT source code中找到了您的第一个错误(按时间顺序排列)的源代码,并附有评论“我们保证只有在Ivy的身份验证失败时才能到达此处”。由于剩余的错误无法找到依赖项,因此看起来代理会导致问题。

您是否看到了问题How to use sbt from behind proxy?您是否尝试过这些步骤?

SBT使用Ivy在本地缓存依赖关系,这样一旦你获取了特定依赖关系的特定版本,就不必再去Internet上再次获取它了。在Windows中,您可以在C:\Users\<User Name>\.ivy2

中查看常春藤缓存的内容

看起来SBT无法通过您公司的代理导致它无法获取第三方依赖项,从而导致构建失败。如果您还没有尝试过,请尝试在SBT命令行或环境变量中设置代理配置。由于您使用的是Windows,只需将-Dhttp.proxyHost=yourserver -Dhttp.proxyPort=port ...添加到SBT命令行即可。确保添加所有必需参数,具体取决于代理所需的内容。 (它需要用户名/密码吗?)

SBT是Scala的“简单构建工具”。 SBT文件是用Scala编写的。 SBT中的类具有定义的运算符,这些运算符会根据您的构建文件导致您请求的构建操作。当您运行sbt package时,您要求构建工具构建并打包当前项目。

Spark quick start解释了simple.sbt文件的高级别。通常,SBT构建文件提供项目名称和版本,定义所需的Scala版本,列出第三方依赖项,并且通常说明了整个构建和打包过程所需的所有内容。