首页 > 解决方案 > 在 armhf 上启用 JProfiler 时出现 UnsatisfiedLinkError

问题描述

我正在尝试在 Raspberry PI 3 上运行的 docker 容器中启动 JProfiler 代理。这是完整的 Dockerfile。

FROM balenalib/raspberrypi3-openjdk

RUN ["cross-build-start"]
RUN curl -SL http://download-keycdn.ej-technologies.com/jprofiler/jprofiler_linux_11_0.tar.gz | tar -xz -C /usr/local && \
  echo 'sudo -u root /usr/local/jprofiler11.0/bin/jpenable -g -p 8849' > /jprofile.sh && \
  chmod +x /jprofile.sh
RUN [ "cross-build-end" ]

ENV JPAGENT_PATH="-agentpath:/usr/local/jprofiler11.0/bin/linux-armhf/libjprofilerti.so=nowait"
ENV JAVA_OPTS=""
EXPOSE 8849

ADD build/libs/myproject-0.0.1-SNAPSHOT.jar /app.jar

ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar

对于分析,运行:

docker exec -it mycontainer /bin/bash -c "/jprofile.sh"

这是完整的输出:

Connecting to app.jar [1] ... ERROR: The agent could not be loaded: Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.tools.attach.LinuxVirtualMachine.isLinuxThreads()Z
        at sun.tools.attach.LinuxVirtualMachine.isLinuxThreads(Native Method)
        at sun.tools.attach.LinuxVirtualMachine.<clinit>(LinuxVirtualMachine.java:343)
        at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
        at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:195)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.jprofiler.attach.proxy.a.e$b.invoke(ejt:110)
        at com.sun.proxy.$Proxy0.attach(Unknown Source)
        at com.jprofiler.attach.a.main(ejt:119)

当我System.loadLibrary("attach")jshell. 任何想法可能导致此异常?

标签: javadockerraspberry-pi3jprofiler

解决方案


通过解决support@ej-technologies.com- 如果您将正确的文件放入lib/libattach.so,您可以将以下代码段添加到 Dockerfile 以使其工作。

对 armhf 的官方支持计划与11.0.1.

# ...
# Add ARMHF remote attach library (acquired via EJ Technologies support)
# See https://stackoverflow.com/questions/56307915/unsatisfiedlinkerror-when-enabling-jprofiler-on-armhf
ADD lib/libattach.so /usr/local/jprofiler11.0/bin/linux-armhf/
RUN chmod a+x /usr/local/jprofiler11.0/bin/linux-armhf/libattach.so

RUN [ "cross-build-end" ]

特别感谢英戈凯格尔!


推荐阅读