我正在尝试使用我的Spring Boot应用程序运行Java docker映像。我想将其用于API测试,也想收集代码覆盖率。但是我无法使jacocoagent在docker容器中运行。难道我做错了什么?我在某处缺少设置吗?当我不添加代理时,常规的bootJar可以平稳运行。此外,我能够在docker env外部执行相同命令而不会出现问题。因此,这似乎不是Java错误。
这是我的docker-compose文件:
version: '3.7'
services:
bootJarTestApi:
image: openjdk:12.0.1-jdk-oracle
environment:
- "JAVA_TOOL_OPTIONS=-javaagent:/jacoco-agent/jacocoagent.jar=destfile=/jacoco-report/apiDockerTest.exec,output=file"
ports:
- 2020:2020
- 2021:2021
volumes:
- "./build/libs/bootJar.jar:/bootJar.jar"
- "./build/libs/jacoco-agent/jacocoagent.jar:/jacoco-agent/jacocoagent.jar"
- "./build/jacoco/:/jacoco-report/"
entrypoint: ["java", "-jar",
# "-javaagent:/jacoco-agent/jacocoagent.jar=destfile=/jacoco-report/apiDockerTest.exec,output=file",
"-Dspring.profiles.active=dev",
"/bootJar.jar"]
当我尝试运行它时,码头工人说:
bootJarTestApi_1 | Picked up JAVA_TOOL_OPTIONS: -javaagent:/jacoco-agent/jacocoagent.jar=destfile=/jacoco-report/apiDockerTest.exec,output=file
bootJarTestApi_1 | FATAL ERROR in native method: processing of -javaagent failed
bootJarTestApi_1 | mmap failed for CEN and END part of zip file
bootJarTestApi_1 | Unexpected error (103) returned by AddToSystemClassLoaderSearch
bootJarTestApi_1 | Unable to add /jacoco-agent/jacocoagent.jar to system class path - the system class loader does not define the appendToClassPathForInstrumentation method or the method failed
bootJarTestApi_1 | #
bootJarTestApi_1 | # A fatal error has been detected by the Java Runtime Environment:
bootJarTestApi_1 | #
bootJarTestApi_1 | # SIGSEGV (0xb) at pc=0x00007f85d2728b07, pid=1, tid=7
bootJarTestApi_1 | #
bootJarTestApi_1 | # JRE version: OpenJDK Runtime Environment (12.0.1+12) (build 12.0.1+12)
bootJarTestApi_1 | # Java VM: OpenJDK 64-Bit Server VM (12.0.1+12, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
bootJarTestApi_1 | # Problematic frame:
bootJarTestApi_1 | # C [libc.so.6+0x37b07] abort+0x297
bootJarTestApi_1 | #
bootJarTestApi_1 | # Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e" (or dumping to //core.1)
bootJarTestApi_1 | #
bootJarTestApi_1 | # An error report file with more information is saved as:
bootJarTestApi_1 | # //hs_err_pid1.log
bootJarTestApi_1 | #
bootJarTestApi_1 | # If you would like to submit a bug report, please visit:
bootJarTestApi_1 | # http://bugreport.java.com/bugreport/crash.jsp
bootJarTestApi_1 | #
bootJarTestApi_1 |
bootJarTestApi_1 | [error occurred during error reporting (), id 0xb, SIGSEGV (0xb) at pc=0x00007f85d2728b07]
答案 0 :(得分:1)
看起来错误消息中的关键行是
mmap failed for CEN and END part of zip file
在Google中对这一行的搜索显示,它始终与文件系统访问相关,但可能是由许多原因引起的-从错误的OS配置到某些文件系统的奇怪行为以及JVM中的错误。因此,我认为这与特定的代理无关,即与JaCoCo代理无关,并且您应该能够与任何其他代理重现相同的内容。
您可以尝试