Java 詹金斯 Maven 构建 137 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24989653/
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
Jenkins Maven Build 137 Error
提问by user2822319
I have a Maven project, which builds 6 separate Maven projects in Jenkins. The problem I face is that over the time the project build fails giving the 137 error code:
我有一个 Maven 项目,它在 Jenkins 中构建了 6 个独立的 Maven 项目。我面临的问题是,随着时间的推移,项目构建失败并给出 137 错误代码:
ERROR: Maven JVM terminated unexpectedly with exit code 137
错误:Maven JVM 意外终止,退出代码为 137
The project could be built successfully using same Maven goals in the console, but in Jenkins it fails. By restarting Jenkins the problem can be resolved.
该项目可以在控制台中使用相同的 Maven 目标成功构建,但在 Jenkins 中它失败了。通过重新启动 Jenkins,可以解决问题。
I have some static array lists. These lists are used for some test cases. Could this be a memory leak?
我有一些静态数组列表。这些列表用于一些测试用例。这可能是内存泄漏吗?
回答by Mateva
I believe you should increase the values of the memory settings - in MAVEN_OPTS
on the Jenkins machine, e.g.
我相信你应该增加内存设置的值 - 在MAVEN_OPTS
Jenkins 机器上,例如
MAVEN_OPTS=-Xmx1.5G -XX:MaxPermSize=0.7G
回答by DTS
I ran into the same error code. This error code does indeed seem related to JVM resource constraints in the Jenkins environment. I would suggest re-running the build a second time after the error occurs to see if you can get additional/different output, though this will certainly depend on which part of the build caused the resource issues (in my cause it was a Maven downloads).
我遇到了相同的错误代码。这个错误代码似乎确实与 Jenkins 环境中的 JVM 资源限制有关。我建议在错误发生后第二次重新运行构建以查看是否可以获得额外/不同的输出,尽管这肯定取决于构建的哪一部分导致资源问题(在我的原因中它是一个 Maven 下载)。
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000fb7cb000, 7331840, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 7331840 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /vagrant/args4java/hs_err_pid10470.log
ERROR: Maven JVM terminated unexpectedly with exit code 1
Finished: FAILURE
回答by boskoop
I was running into the same behavior on our build server. The error is IMHO not associated with the maven memory settings (i.e. MAVEN_OPTS
) but rather with the memory of the underlying (Linux) machine itself (which Jenkins runs on).
我在我们的构建服务器上遇到了相同的行为。恕我直言,错误与 maven 内存设置(即MAVEN_OPTS
)无关,而是与底层(Linux)机器本身(Jenkins 在其上运行)的内存相关。
The (rejected) Jenkins issue https://jenkins-ci.org/issue/12035gives more detail on this matter:
(被拒绝的)Jenkins 问题https://jenkins-ci.org/issue/12035提供了有关此问题的更多详细信息:
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.
作为参考,状态代码 137 (128 + 9) 通常意味着(可能因 unix 的不同而不同)。该过程因收到信号而终止。在这种情况下,信号 9 是 SIGKILL 和不可阻止的杀死。
如果是这种情况,底层机器/操作系统需要更多的虚拟内存。这可以通过适当地添加物理内存或交换空间来添加。
You should try to increase the virtual memory of your machine.
您应该尝试增加机器的虚拟内存。
Note:
This also explains why a Jenkins restart (temporarily) fixes the issue.
注意:
这也解释了为什么 Jenkins 重启(临时)解决了这个问题。
回答by Scott Izu
When running Maven via Jenkins I got this error:
通过 Jenkins 运行 Maven 时出现此错误:
ERROR: Maven JVM terminated unexpectedly with exit code 137
I accidently put an "and" in the MAVEN_OPTS parameter:
我不小心在 MAVEN_OPTS 参数中放了一个“和”:
-Xmx1024m and -Xms1024m
Then, I got this error:
然后,我收到了这个错误:
Error: Could not find or load main class and
ERROR: Failed to launch Maven. Exit code - 1
After, removing the 'and', I reran Jenkins and received this error:
之后,删除“和”,我重新运行詹金斯并收到此错误:
java.lang.OutOfMemoryError: Java heap space
Finally, I increased the memory using Global MAVEN_OPTS:
最后,我使用 Global MAVEN_OPTS 增加了内存:
-Xmx4096m -Xms4096m
This fixed the problem. So, this seems to be related to memory. However, it could be a machine/VM related issue (as @boskoop stated above) or a container issue (if JVM is run through Jenkins/Docker/etc).
这解决了问题。所以,这似乎与记忆有关。但是,它可能是与机器/VM 相关的问题(如上面@boskoop 所述)或容器问题(如果 JVM 通过 Jenkins/Docker/等运行)。
回答by Mykhaylo Adamovych
If you machine has at least 2 processors and 4GB memory, your JVM will not only grab 1GB at startup but will turn -server mode, meaning memory will be retained for performance sake (source). If you have few JVMs running at the same time (several application components, maven builds etc.) you can easily get into low memory. And you one of you JVM may be killed by Linux OOM Killerbecause you are low on resources on the machine.
如果您的机器至少有 2 个处理器和 4GB 内存,那么您的 JVM 不仅会在启动时占用 1GB,还会转为 -server 模式,这意味着为了性能将保留内存(来源)。如果您同时运行的 JVM 很少(多个应用程序组件、maven 构建等),您很容易进入低内存状态。而你们中的一个 JVM 可能会被Linux OOM Killer杀死,因为您机器上的资源不足。
Reduce memory footprint of your process which is directly impactedby jvm default Xmx, which most probably is far from what jvm actually need.
减少受jvm 默认 Xmx直接影响的进程的内存占用,这很可能与 jvm 实际需要的相差甚远。
Give it additional java command line options
给它额外的 java 命令行选项
-Xmx256m -XX:MaxPermSize=512m
or configure system variable
或配置系统变量
MAVEN_OPTS=-Xmx256m -XX:MaxPermSize=512m
MaxPermSize have no use for java 8+
MaxPermSize 对 java 8+ 没有用