Search code examples
dockeralpine-linuxjprofileropenj9

How to setup remote profiling with JProfiler 12.0.3 on OpenJ9/Alpine container


I am trying to setup an alpine linux docker container with jprofiler 12.0.3, so that I can connect to it remotely.

In my Dockerfile:

FROM adoptopenjdk/openjdk11-openj9:alpine-slim
...
RUN wget https://download-gcdn.ej-technologies.com/jprofiler/jprofiler_linux_12_0_3.tar.gz -P /jprofiler/ && tar -xzf jprofiler_linux_12_0_3.tar.gz -C /jprofiler && rm /jprofiler/jprofiler_linux_12_0_3.tar.gz
ENTRYPOINT ["./startup.sh"]

And in my startup.sh file:

...
JAVA_OPTS="$JAVA_OPTS -agentpath:/jprofiler/jprofiler12.0.3/bin/linux_musl-x64/libjprofilerti.so=port=8849,nowait"
...

However, when I build and then run the docker image using the Dockerfile above, I get:

Starting app with JAVA_OPTS:  -agentpath:/jprofiler/jprofiler12.0.3/bin/linux_musl-x64/libjprofilerti.so=port=8849,nowait
JProfiler> Protocol version 64
JProfiler> Thread status info workaround enabled.
JProfiler> OpenJ9 JVMTI version 1.1 detected.
JProfiler> Java 11 detected.
JProfiler> Don't wait for frontend to connect.
JProfiler> 64-bit library (musl)
JProfiler> Could not locate the config file.
JProfiler> Please specify config=[config filename].
JProfiler> If you are running JProfiler's frontend on a different
JProfiler> machine you have to copy the file jprofiler_config.xml to this
JProfiler> computer. The file is located in $HOME/.jprofiler12 or
JProfiler> in C:\Users\[username]\.jprofiler12.

If I change the base image to a hotspot one like this for example:

FROM adoptopenjdk:11-jre-hotspot-focal
...
RUN wget https://download-gcdn.ej-technologies.com/jprofiler/jprofiler_linux_12_0_3.tar.gz -P /jprofiler/ && tar -xzf jprofiler_linux_12_0_3.tar.gz -C /jprofiler && rm /jprofiler/jprofiler_linux_12_0_3.tar.gz
ENTRYPOINT ["./startup.sh"]

And startup.sh to:

... 
JAVA_OPTS="$JAVA_OPTS -agentpath:/jprofiler/jprofiler12.0.3/bin/linux_musl-x64/libjprofilerti.so=port=8849,nowait"    
...

I get, the following output and I can connect to this JVM remotely with JProfiler:

Starting app with JAVA_OPTS:  -agentpath:/jprofiler/jprofiler12.0.3/bin/linux-x64/libjprofilerti.so=port=8849,nowait
JProfiler> Protocol version 64
JProfiler> Java 11 detected.
JProfiler> Don't wait for frontend to connect.
JProfiler> 64-bit library
JProfiler> Starting up without initial configuration.
JProfiler> Listening on port: 8849.
JProfiler> Enabling native methods instrumentation.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
JProfiler> Retransforming 162 base class files.
JProfiler> Base classes instrumented.

Would you happen to know why the alpine image behaves this way and if there is any way to fix this config file issue?


Solution

  • The difference is between the OpenJ9 and the Hotspot VMs. For OpenJ9 JProfiler needs the profiling settings at startup, so you have to specify the "config" option for the -agentpath parameter.

    You can use the remote integration wizard (Session->Integration wizards->New Remote Integration) integration to get help with settings this up.