最近新接觸scala代碼的編寫魁蒜、編譯囊扳,使用mvn編譯項目時經(jīng)常碰到“ExecuteException: Process exited with an error: 1 (Exit value: 1)” 。特別是在mvn clean再mvn package時兜看,很容易出現(xiàn)锥咸。
另外,從錯誤日志上看不到具體是哪行代碼編譯有問題细移,找不到原因搏予,很無奈。
最近一次出現(xiàn)該問題是從spark2.1.1中copy了spark-streaming-kafka-0-10_2.11子項目的源碼弧轧,精簡pom.xml之后編譯雪侥,又出現(xiàn)這類問題,詳細(xì)日志如下:
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.2:compile (default) on project yisou-spark-streaming-kafka-0-10_2.11: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.2:compile (default) on project yisou-spark-streaming-kafka-0-10_2.11: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at scala_maven.ScalaMojoSupport.execute(ScalaMojoSupport.java:490)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
走了許多彎路之后(如修改scala版本號精绎、更換maven-scala-plugin速缨、完全復(fù)制源碼的pom等),最后意外發(fā)現(xiàn)pom中去掉
guava的exclusion就沒問題了捺典。
會報錯的pom:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.binary.version}</artifactId>
<version>2.1.1</version>
<type>test-jar</type>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
</dependency>
能正常運(yùn)行的pom:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.binary.version}</artifactId>
<version>2.1.1</version>
<type>test-jar</type>
<scope>provided</scope>
</dependency>
為什么加了exclusion guava就編譯報錯了呢鸟廓,如果是exclusion 其他的artifactId并沒有此問題。spark-streaming-kafka-0-10_2.11源碼中并沒有使用guava的類襟己。
我也暫時沒查出原因引谜,在此提醒遇到類似問題的朋友,多從pom配置而不是代碼入手擎浴,特別注意guava的exclusion很可能會造成此問題员咽。