java 命令“mvn package”失败,状态为 137
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6773726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
command "mvn package" fails with status 137
提问by basilboli
Packaging GWT project using "mvn package" fails and I have the following ouput:
使用“mvn package”打包 GWT 项目失败,我有以下输出:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [apt:process {execution: default}]
[INFO] [aspectj:compile {execution: default}]
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [aspectj:test-compile {execution: default}]
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Not compiling test sources
[INFO] [surefire:test {execution: default-test}]
[INFO] Tests are skipped.
[INFO] [gwt:compile {execution: gwtcompile}]
[INFO] Compiling module com.MyProject
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Command [[
/bin/sh -c /usr/lib/jvm/java-6-sun-1.6.0.24/jre/bin/java -XX:MaxPermSize=256M -Xmx512M -classpath /home/projects/MyProject/trunk/src/main/java:/home/projects/MyProject/trunk/target/generated-sources/java:/home/projects/MyProject/trunk/src/main/aspect:/home/projects/MyProject/trunk/src/main/resources:/home/projects/MyProject/trunk/src/main/webapp/WEB-INF/classes:/root/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar:/root/.m2/repository/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar:/root/.m2/repository/org/slf4j/jcl-over-slf4j/1.6.1/jcl-over-slf4j-1.6.1.jar:/root/.m2/repository/org/slf4j/jul-to-slf4j/1.6.1/jul-to-slf4j-1.6.1.jar:/root/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar:/root/.m2/repository/org/aspectj/aspectjrt/1.6.11.M1/aspectjrt-1.6.11.M1.jar:/root/.m2/repository/org/aspectj/aspectjweaver/1.6.11.M1/aspectjweaver-1.6.11.M1.jar:/root/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/root/.m2/repository/net/sf/flexjson/flexjson/2.0/flexjson-2.0.jar:/root/.m2/repository/org/springframework/spring-core/3.0.5.RELEASE/spring-core-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/spring-asm/3.0.5.RELEASE/spring-asm-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/spring-context/3.0.5.RELEASE/spring-context-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/spring-aop/3.0.5.RELEASE/spring-aop-3.0.5.RELEASE.jar:/root/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/root/.m2/repository/org/springframework/spring-beans/3.0.5.RELEASE/spring-beans-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/spring-expression/3.0.5.RELEASE/spring-expression-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/spring-aspects/3.0.5.RELEASE/spring-aspects-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/spring-context-support/3.0.5.RELEASE/spring-context-support-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/spring-tx/3.0.5.RELEASE/spring-tx-3.0.5.RELEASE.jar:/root/.m2/repository/com/h2database/h2/1.3.148/h2-1.3.148.jar:/root/.m2/repository/mysql/mysql-connector-java/5.1.13/mysql-connector-java-5.1.13.jar:/root/.m2/repository/org/hibernate/hibernate-core/3.6.0.Final/hibernate-core-3.6.0.Final.jar:/root/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar:/root/.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar:/root/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/root/.m2/repository/org/hibernate/hibernate-commons-annotations/3.2.0.Final/hibernate-commons-annotations-3.2.0.Final.jar:/root/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.0.Final/hibernate-jpa-2.0-api-1.0.0.Final.jar:/root/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar:/root/.m2/repository/org/hibernate/hibernate-entitymanager/3.6.0.Final/hibernate-entitymanager-3.6.0.Final.jar:/root/.m2/repository/javassist/javassist/3.12.0.GA/javassist-3.12.0.GA.jar:/root/.m2/repository/org/hibernate/hibernate-validator/4.1.0.Final/hibernate-validator-4.1.0.Final.jar:/root/.m2/repository/javax/validation/validation-api/1.0.0.GA/validation-api-1.0.0.GA.jar:/root/.m2/repository/javax/validation/validation-api/1.0.0.GA/validation-api-1.0.0.GA-sources.jar:/root/.m2/repository/cglib/cglib-nodep/2.2/cglib-nodep-2.2.jar:/root/.m2/repository/org/springframework/spring-jdbc/3.0.5.RELEASE/spring-jdbc-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/spring-orm/3.0.5.RELEASE/spring-orm-3.0.5.RELEASE.jar:/root/.m2/repository/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar:/root/.m2/repository/commons-dbcp/commons-dbcp/1.3/commons-dbcp-1.3.jar:/root/.m2/repository/org/springframework/spring-web/3.0.5.RELEASE/spring-web-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/spring-webmvc/3.0.5.RELEASE/spring-webmvc-3.0.5.RELEASE.jar:/root/.m2/repository/org/springframework/webflow/spring-js-resources/2.2.1.RELEASE/spring-js-resources-2.2.1.RELEASE.jar:/root/.m2/repository/commons-digester/commons-digester/2.0/commons-digester-2.0.jar:/root/.m2/repository/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar:/root/.m2/repository/commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar:/root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar:/root/.m2/repository/javax/el/el-api/1.0/el-api-1.0.jar:/root/.m2/repository/joda-time/joda-time/1.6/joda-time-1.6.jar:/root/.m2/repository/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar:/root/.m2/repository/com/google/gwt/gwt-user/2.3.0/gwt-user-2.3.0.jar:/root/.m2/repository/com/sun/jersey/jersey-client/1.5/jersey-client-1.5.jar:/root/.m2/repository/com/sun/jersey/jersey-core/1.5/jersey-core-1.5.jar:/root/.m2/repository/org/json/json/20090211/json-20090211.jar:/root/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar:/home/projects/MyProject/trunk/lib/gwt-incubator.jar:/root/.m2/repository/com/google/gwt/inject/gin/1.5.0/gin-1.5.0.jar:/root/.m2/repository/com/google/inject/guice/3.0/guice-3.0.jar:/root/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/root/.m2/repository/com/google/inject/extensions/guice-assistedinject/3.0/guice-assistedinject-3.0.jar:/root/.m2/repository/xalan/xalan/2.7.1/xalan-2.7.1.jar:/root/.m2/repository/xalan/serializer/2.7.1/serializer-2.7.1.jar:/root/.m2/repository/xml-apis/xml-apis/1.3.04/xml-apis-1.3.04.jar:/root/.m2/repository/com/mysema/querydsl/querydsl-apt/2.1.2/querydsl-apt-2.1.2.jar:/root/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar:/root/.m2/repository/com/mysema/querydsl/querydsl-core/2.1.2/querydsl-core-2.1.2.jar:/root/.m2/repository/net/sourceforge/collections/collections-generic/4.01/collections-generic-4.01.jar:/root/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:/root/.m2/repository/com/mysema/commons/mysema-commons-lang/0.2.1/mysema-commons-lang-0.2.1.jar:/root/.m2/repository/com/mysema/codegen/codegen/0.3.1/codegen-0.3.1.jar:/root/.m2/repository/net/sourceforge/findbugs/jsr305/1.3.2/jsr305-1.3.2.jar:/root/.m2/repository/net/sourceforge/findbugs/annotations/1.3.2/annotations-1.3.2.jar:/root/.m2/repository/com/mysema/querydsl/querydsl-jpa/2.1.2/querydsl-jpa-2.1.2.jar:/root/.m2/repository/cglib/cglib/2.2/cglib-2.2.jar:/root/.m2/repository/asm/asm/3.1/asm-3.1.jar:/root/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/root/.m2/repository/javax/mail/mail/1.4.4/mail-1.4.4.jar:/root/.m2/repository/org/mindrot/jbcrypt/0.3m/jbcrypt-0.3m.jar:/root/.m2/repository/com/google/gwt/gwt-user/2.3.0/gwt-user-2.3.0.jar:/root/.m2/repository/com/google/gwt/gwt-dev/2.3.0/gwt-dev-2.3.0.jar com.google.gwt.dev.Compiler -gen /home/projects/MyProject/trunk/target/.generated -logLevel INFO -style OBF -war /home/projects/MyProject/trunk/target/MyProject-0.1.0.BUILD-SNAPSHOT -localWorkers 1 com.MyProject
]] failed with status 137}
- Machine is Debian 6.0
- java version "1.6.0_24", Java(TM) SE Runtime Environment (build 1.6.0_24-b07), Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
- maven compiler plugin excerpt from pom.xml: 1.6 1.6
- 机器是 Debian 6.0
- java 版本“1.6.0_24”,Java(TM) SE 运行时环境(构建 1.6.0_24-b07),Java HotSpot(TM)64 位服务器 VM(构建 19.1-b02,混合模式)
- 来自 pom.xml 的 maven 编译器插件摘录:1.6 1.6
Has anyone faced the same problem? Thank you very much in advance.
有没有人遇到过同样的问题?非常感谢您提前。
回答by Piotr Sobczyk
I was able to solve this problem by adding a swap file to the system (there was had no swap at all).
我能够通过向系统添加交换文件来解决这个问题(根本没有交换)。
For more details about the reason of that problem look here.
有关该问题原因的更多详细信息,请查看此处。
This is the key fragment:
这是关键片段:
In that case the problem was the linux kernel running out of virtual memory. The kernel OOM (out of memory) killer then stepped in and killed the most (un)deserving victim/runaway process which happened to be the GWT/maven build process.
To determine if that is the case you can use the {{dmesg}} command from a linux shell. Somewhere towards the end of the output there will be a line similar to
{code} Out of memory: kill process 946 (daemon) score 1073527 or a child {code}
For reference the status code 137 (128 + 9) typically means (can differ between flavours of unix). That the process was terminated by receipt of a signal. In this case signal 9 which is SIGKILL and unblockable kill.
If this is the case the underlying machine/OS needs more virtual memory. This can be added by either adding physical memory or swap space as appropriate.
在那种情况下,问题是 linux 内核耗尽了虚拟内存。内核 OOM(内存不足)杀手随后介入并杀死了最(不)应得的受害者/失控进程,这恰好是 GWT/maven 构建进程。
要确定是否是这种情况,您可以使用 linux shell 中的 {{dmesg}} 命令。在输出末尾的某个地方会有一条类似于
{code} 内存不足:kill process 946 (daemon) score 1073527 or a child {code}
作为参考,状态代码 137 (128 + 9) 通常意味着(可能因 unix 的不同而不同)。该过程因收到信号而终止。在这种情况下,信号 9 是 SIGKILL 和不可阻止的杀死。
如果是这种情况,底层机器/操作系统需要更多的虚拟内存。这可以通过适当地添加物理内存或交换空间来添加。
回答by Adam Burley
For me, I found that the problem was too much memory being allocated, not too little.
对我来说,我发现问题是分配的内存太多,而不是太少。
When running the job on a machine with 2GB of memory and setting the max heap size to 2GB, the build eventually failed with status 137. However when setting the job to 1GB maximum (e.g. -Xmx1g -Xms512m
), the build succeeded.
在具有 2GB 内存的机器上运行作业并将最大堆大小设置为 2GB 时,构建最终失败,状态为 137。但是,当将作业设置为最大 1GB(例如-Xmx1g -Xms512m
)时,构建成功。
This kind of makes sense, because the JVM will freely increase its memory up to the maximum heap size, but if there's not enough real memory, the OS will kill the process. However, if you reduce the max heap size, the JVM won't try to increase its memory so highly, so the OS won't worry about it enough to kill it.
这是有道理的,因为 JVM 会自由地将其内存增加到最大堆大小,但是如果实际内存不足,操作系统将终止该进程。但是,如果您减少最大堆大小,JVM 不会尝试将其内存增加得如此之大,因此操作系统不会担心它足以杀死它。
Furthermore, I was using GWT which forks a separate process for compilation, and the arguments have to be specified as an extraJvmArgs
element within gwt-maven-plugin
configuration, not in MAVEN_OPTS
.
此外,我使用的 GWT 分叉了一个单独的编译过程,并且必须将参数指定为配置中的extraJvmArgs
元素gwt-maven-plugin
,而不是MAVEN_OPTS
.
回答by Sinc
I had this problem and my system admin found a number of hung processes on the Bamboo server. Clearing those processes resolved the issue. It may not be anything directly to do with your own build.
我遇到了这个问题,我的系统管理员在 Bamboo 服务器上发现了许多挂起的进程。清除这些进程解决了这个问题。它可能与您自己的构建没有任何直接关系。
回答by Tahir Akhtar
Try another version (or a fresh installation) of JDK/JRE. It looks like java executable is crashing while running GWT compiler. You can also try to compile it another machine to confirm that the problem is with the JDK/JRE installation.
尝试另一个版本(或全新安装)的 JDK/JRE。看起来 java 可执行文件在运行 GWT 编译器时崩溃了。您也可以尝试在另一台机器上编译它以确认问题出在JDK/JRE安装上。