【问题标题】:Why does running Spark application using "sbt run" fail in sbt 1.0.x?为什么在 sbt 1.0.x 中使用“sbt run”运行 Spark 应用程序失败?
【发布时间】:2018-05-27 12:39:58
【问题描述】:

我有一个简单的 Spark 项目,我尝试使用 sbt run 运行它。但是在代码生成期间会导致异常:

17/12/13 15:19:27 ERROR CodeGenerator: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 15, Column 34: Cannot determine simple type name "scala"
/* 001 */ public Object generate(Object[] references) {
/* 002 */   return new GeneratedIterator(references);
/* 003 */ }
/* 004 */
/* 005 */ final class GeneratedIterator extends org.apache.spark.sql.execution.BufferedRowIterator {
/* 006 */   private Object[] references;
/* 007 */   private scala.collection.Iterator[] inputs;
/* 008 */   private org.apache.spark.sql.execution.metric.SQLMetric scan_numOutputRows;
/* 009 */   private scala.collection.Iterator scan_input;
/* 010 */
/* 011 */   public GeneratedIterator(Object[] references) {
/* 012 */     this.references = references;
/* 013 */   }
/* 014 */
/* 015 */   public void init(int index, scala.collection.Iterator[] inputs) {
/* 016 */     partitionIndex = index;
/* 017 */     this.inputs = inputs;
/* 018 */     this.scan_numOutputRows = (org.apache.spark.sql.execution.metric.SQLMetric) references[0];
/* 019 */     scan_input = inputs[0];
/* 020 */
/* 021 */   }
/* 022 */
/* 023 */   protected void processNext() throws java.io.IOException {
/* 024 */     while (scan_input.hasNext()) {
/* 025 */       InternalRow scan_row = (InternalRow) scan_input.next();
/* 026 */       scan_numOutputRows.add(1);
/* 027 */       append(scan_row);
/* 028 */       if (shouldStop()) return;
/* 029 */     }
/* 030 */   }
/* 031 */ }

org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 15, Column 34: Cannot determine simple type name "scala"

spark-submit 不会发生这种情况。构建定义最少:

name := "untitled"

version := "0.1"

scalaVersion := "2.11.12"

libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-sql" % "2.2.1"
)

代码也是如此(我会发布它,有人认为它是相关的,但我认为问题是一般性的)和build.properties

sbt.version = 1.0.4

据我了解,这是因为 Spark 在运行时找不到 Scala 库 - 这是正确的吗?

【问题讨论】:

    标签: scala apache-spark sbt apache-spark-sql


    【解决方案1】:

    我最近注意到使用 sbt 1.0.x 会以某种方式通过sbt run 中断 Spark 应用程序的执行。

    我的猜测是,根本原因可能是 sbt 1.0.x 在幕后使用的 Scala 2.12.x,以某种方式触发了问题。

    在问题解决之前,我建议使用spark-submit 运行 Spark 应用程序。

    【讨论】:

    • 这也可能与 sbt 1 中的 bgrun 更改有关,这是对 sbt run 所做的非常根本的更改
    猜你喜欢
    • 2017-11-02
    • 2019-05-22
    • 1970-01-01
    • 2019-11-04
    • 2018-02-21
    • 2019-02-24
    • 1970-01-01
    • 2017-01-06
    • 2018-09-24
    相关资源
    最近更新 更多