How to configure Java location while attaching profiler

Questions about YourKit Java Profiler
Locked
vartikarai
Posts: 3
Joined: Wed Jan 20, 2021 3:37 pm

How to configure Java location while attaching profiler

Post by vartikarai »

I am trying to attach profiler to java application running on linux environment. But it is failing as it can not find the java file path. Is the java path hard coded anywhere ? Because it is not picking from JAVA_HOME environment variable. It is always trying to find the java under /usr/lib/jvm/java-11-openjdk-11.0.9.11-2.el7_9.x86_64/bin/java
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: How to configure Java location while attaching profiler

Post by Anton Katilin »

Do you try to attach from the profiler UI or with the console wizard?

Is the target process local or remote?

Exactly what error do you get?
vartikarai
Posts: 3
Joined: Wed Jan 20, 2021 3:37 pm

Re: How to configure Java location while attaching profiler

Post by vartikarai »

I am trying to attach through command line on a linux environment bu running the attach.sh.

Attaching to process pid using default options
Exception in thread "main" com.yourkit.af.bg: Cannot execute command:
/usr/lib/jvm/java-11-openjdk-11.0.9.11-2.el7_9.x86_64/bin/java
-Dfile.encoding=UTF-8

ause: java.io.IOException: Cannot run program "/usr/lib/jvm/java-11-openjdk-11.0.9.11-2.el7_9.x86_64/bin/java": error=2, No such file or directory
at com.yourkit.af.bh.c(a:154)
at com.yourkit.attach.c.d(a:289)
at com.yourkit.attach.c.a(a:139)
at com.yourkit.attach.b.d(a:65)
at com.yourkit.Main.b(a:297)
at com.yourkit.Main.main(a:157)
Caused by: java.io.IOException: Cannot run program "/usr/lib/jvm/java-11-openjdk-11.0.9.11-2.el7_9.x86_64/bin/java": error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at com.yourkit.af.bh.c(a:151)
... 5 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107

Also with jdk 11 I am getting another error.
I was able to attach to a running jvm earlier. But when I am trying now it is refusing with error

com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /proc/12525/root/tmp/.java_pid12525: target process 12525 doesn't respond within 10500ms or HotSpot VM not loaded
| at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:100)
| at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
| at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
| at com.yourkit.Attach.a(a:43)
| at com.yourkit.Attach.main(a:38)
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: How to configure Java location while attaching profiler

Post by Anton Katilin »

Could you please send the full log file to [email protected]

What is the output for the following commands:

file /usr/lib/jvm/java-11-openjdk-11.0.9.11-2.el7_9.x86_64/bin/java
ls -l /usr/lib/jvm/java-11-openjdk-11.0.9.11-2.el7_9.x86_64/bin/java
/usr/lib/jvm/java-11-openjdk-11.0.9.11-2.el7_9.x86_64/bin/java -version

> Also with jdk 11 I am getting another error.
Do you mean you attach to 2 different processes which gives different errors?
vartikarai
Posts: 3
Joined: Wed Jan 20, 2021 3:37 pm

Re: How to configure Java location while attaching profiler

Post by vartikarai »

Since profiler was not working with JDK 8 so I installed JDK11 and tried to attach the profiler to same process but this time I am getting below error. Can you please tell me which version supports java 8?

com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /proc/12525/root/tmp/.java_pid12525: target process 12525 doesn't respond within 10500ms or HotSpot VM not loaded
| at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:100)
| at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
| at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
| at com.yourkit.Attach.a(a:43)
| at com.yourkit.Attach.main(a:38)
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: How to configure Java location while attaching profiler

Post by Anton Katilin »

Profiling of Java 8 is fully supported in the current profiler version. The console wizards should also run on Java 8.

We need to understand what you're doing. Could you please provide the full log as I requested.
Locked