spark點點滴滴 —— 運行scala任務異常處理__scala

來源:互聯網
上載者:User

spark版本:2.0.1
最近在用spark提交scala語言寫的任務時,提交任務總是失敗,異常如下:

17/05/05 18:39:23 ERROR yarn.ApplicationMaster: User class threw exception: java.lang.NoSuchMethodError: scala.reflect.api.JavaUniverse.runtimeMirror(Ljava/lang/ClassLoader;)Lscala/reflect/api/JavaMirrors$JavaMirror;java.lang.NoSuchMethodError: scala.reflect.api.JavaUniverse.runtimeMirror(Ljava/lang/ClassLoader;)Lscala/reflect/api/JavaMirrors$JavaMirror;    at LRPipeline$.main(LRPipeline.scala:17)    at LRPipeline.main(LRPipeline.scala)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:497)    at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2.run(ApplicationMaster.scala:627)17/05/05 18:39:23 INFO yarn.ApplicationMaster: Final app status: FAILED, exitCode: 15, 

網上尋找了半天,結合自己測試,終於解決了,解決過程如下:
我的原始maven配置如下:

 <properties>        <scala.version>2.10.6</scala.version>    </properties>    <dependencies>        <dependency>            <groupId>org.apache.spark</groupId>            <artifactId>spark-core_2.11</artifactId>            <version>2.0.1</version>        </dependency>        <dependency>            <groupId>org.apache.spark</groupId>            <artifactId>spark-mllib_2.11</artifactId>            <version>2.0.1</version>        </dependency>        <dependency>            <groupId>org.apache.spark</groupId>            <artifactId>spark-sql_2.11</artifactId>            <version>2.0.1</version>        </dependency>        <dependency>            <groupId>org.scala-lang</groupId>            <artifactId>scala-library</artifactId>            <version>${scala.version}</version>            <scope>compile</scope>        </dependency>        <dependency>            <groupId>org.scala-lang</groupId>            <artifactId>scala-reflect</artifactId>            <version>${scala.version}</version>        </dependency>    </dependencies>

首先,可以確認spark2.0.1使用的scala版本時2.11.8,而上述maven中我使用的配置是2.10.6,因此嘗試調整scala版本

調整版本後,繼續mvn package編譯,提交spark任務,問題依舊存在。

追查半天,最終發現竟然是替換maven中scala版本後,居然忘記mvn clean清理項目編譯後再重新mvn package打包。導致maven的更改未生效。

關於有沒有clean命令有什麼不一樣的地方,可以參考網友的整理,見這裡。

因此,執行mvn clean package,重新打包,提交任務後,運行成功。。。

把這個記錄在此,希望大家都能少遇到一些坑。

【參考】http://stackoverflow.com/questions/40128956/getting-exception-java-lang-nosuchmethoderror-scala-reflect-api-javauniverse

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.