我正在尝试在我的本地机器上安装 Spark。我一直在关注 this指导。我已安装 JDK-7
(也有 JDK-8
)和 Scala 2.11.7
.当我尝试使用 sbt
时出现问题建Spark 1.4.1
.我得到以下异常。
NOTE: The sbt/sbt script has been relocated to build/sbt.
Please update references to point to the new location.
Invoking 'build/sbt assembly' now ...
Attempting to fetch sbt
Launching sbt from build/sbt-launch-0.13.7.jar
Error: Invalid or corrupt jarfile build/sbt-launch-0.13.7.jar
我一直在寻找解决这个问题的方法。我找到了一个不错的指南 https://stackoverflow.com/a/31597283/2771315它使用预先构建的版本。除了使用预建版本,还有没有安装
Spark
的方法使用 sbt
?此外,是否有理由解释为什么 Invalid or corrupt jarfile
发生错误?
最佳答案
我遇到了同样的问题。我现在已经修好了。
这可能是因为 sbt-launch-0.13.7.jar 下载失败,虽然可以看到文件存在,但不是正确的文件。文件是 约 1.2MB 在尺寸方面。如果少于这个,你可以进入 build/,使用“vim sbt-launch-0.13.7.jar”或其他工具到 打开 sbt-launch-0.13.7.jar 文件。
如果文件有这样的内容:
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
这意味着未下载 sbt-launch-0.13.7.jar。
然后打开 sbt-launch-lib.bash 在同一目录中,检查第 41 和 42 行,它给出了两个 url。打开它以检查它们是否工作正常。
如果 url1 不起作用,请下载 sbt-launch.jar 手动(可以用url2,也可以,也可以从sbt官网下载),放到同目录下,将其重命名为 sbt-launch-0.13.7.jar ,然后你应该注释掉与下载相关的行(可能在第 47 行和第 68 行之间),避免脚本再次下载。像这样:
acquire_sbt_jar () {
SBT_VERSION=`awk -F "=" '/sbt\.version/ {print $2}' ./project/build.properties`
URL1=http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/${SBT_VERSION}/sbt-launch.jar
URL2=http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/${SBT_VERSION}/sbt-launch.jar
JAR=build/sbt-launch-${SBT_VERSION}.jar
sbt_jar=$JAR
# if [[ ! -f "$sbt_jar" ]]; then
# # Download sbt launch jar if it hasn't been downloaded yet
# if [ ! -f "${JAR}" ]; then
# # Download
# printf "Attempting to fetch sbt\n"
# JAR_DL="${JAR}.part"
# if [ $(command -v curl) ]; then
# (curl --silent ${URL1} > "${JAR_DL}" || curl --silent ${URL2} > "${JAR_DL}") && mv "${JAR_DL}" "${JAR}"
# elif [ $(command -v wget) ]; then
# (wget --quiet ${URL1} -O "${JAR_DL}" || wget --quiet ${URL2} -O "${JAR_DL}") && mv "${JAR_DL}" "${JAR}"
# else
# printf "You do not have curl or wget installed, please install sbt manually from http://www.scala-sbt.org/\n"
# exit -1
# fi
# fi
# if [ ! -f "${JAR}" ]; then
# # We failed to download
# printf "Our attempt to download sbt locally to ${JAR} failed. Please install sbt manually from http://www.scala-sbt.org/\n"
# exit -1
# fi
# printf "Launching sbt from ${JAR}\n"
# fi
}
然后使用“build/sbt assembly”再次构建 Spark 。
希望你会成功。
如果我没有表达清楚,以下链接可能会有所帮助。
https://www.mail-archive.com/user@spark.apache.org/msg34358.html
Error: Invalid or corrupt jarfile sbt/sbt-launch-0.13.5.jar prabeesh 的回答
https://groups.google.com/forum/#!topic/predictionio-user/fllCh8n-0d4
关于scala - 使用 SBT : Invalid or corrupt jarfile 构建 Apache Spark,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31637752/