Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

command "mvn package" fails with status 137

Tags:

java

maven

gwt

Packaging GWT project using "mvn package" fails and I have the following ouput:

[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

Has anyone faced the same problem? Thank you very much in advance.

like image 567
basilboli Avatar asked Jul 21 '11 09:07

basilboli


2 Answers

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.

like image 168
Piotr Sobczyk Avatar answered Nov 09 '22 14:11

Piotr Sobczyk


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.

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.

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.

like image 23
Adam Burley Avatar answered Nov 09 '22 15:11

Adam Burley