简体   繁体   中英

UnsatisfiedLinkError when running jpenable in alpine / Jprofile 10

When running jpenable to permit profiling for Jprofiler10 in an alpine:3.3 container running JDK 8, I'm getting an UnsatisfiedLinkError exception. Any ideas?

ERROR: The agent could not be loaded: Picked up _JAVA_OPTIONS: -Xmx1024m
Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/jprofiler10/bin/
linux-x64/libattach.so: Error relocating /opt/jprofiler10/bin/linux-x64/libattac
h.so: __strcpy_chk: symbol not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.jprofiler.attach.b.b.b.load(ejt:6)
at com.jprofiler.attach.b.b.i.loadLibraryPath(ejt:49)
at com.jprofiler.attach.a.b(ejt:92)
at com.jprofiler.attach.a.a(ejt:74)
at com.jprofiler.attach.a.main(ejt:116)

So, I'll answer my own question.

First - I noticed that ldd showed MOST of the java native libraries were broken (not resolving dependent libraries) in the alpine:3.5 openjdk8-jre package. I found a solution to configure the load library path here: https://github.com/docker-library/openjdk/issues/77

Creating a /etc/ld-musl-x86_64.path with the following content fixed most of the library problems that I found with ldd.

/lib
/usr/lib
/usr/local/lib
/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64
/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/jli
/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server
/opt/jprofiler10.1.1/bin/linux-x64/

However the /opt/jprofiler10.1.1/bin/linux-x64/libattach.so provided in the Jprofiler10 tar file was still broken, so I deleted it - and used the libattach.so contained in the /usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64 directory.

The following Dockerfile shows how I built the container - and fixed the problems.

FROM alpine:3.5
RUN apk --no-cache add \
    openjdk8-jre-base \
    libstdc++
COPY ld-musl-x86_64.path /etc/ld-musl-x86_64.path
ADD jprofiler_linux_10_1_1.tar /opt/
RUN rm /opt/jprofiler10.1.1/bin/linux-x64/libattach.so 

After this - I was able to bring the container up in rancher.

The final steps were to exec shell into the container and run jpenable to enable the Jprofiler tool to create a connection to the jvm.

eg /opt/jprofiler10.1.1/bin/jpenable

I was able to then connect on port 8849 and profile the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM