Search code examples
profilingsprayyourkit

Profiling Spray HTTP Application using Yourkit


I have a Spray based HTTP application running on a remote machine and I would like to profile it using Yourkit. I followed the instructions as mentioned in the Yourkit website and I ended up hitting this error:

root@remote-worker:/home/joe/yjp-2016.02/bin# sh yjp.sh -attach 19960
Attaching to process 19960 using default options
[YourKit Java Profiler 2016.02-b36] Log file: /root/.yjp/log/yjp-23609.log
com.yourkit.runtime.PresentableException: com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
    at com.yourkit.f.a.a(a:93)
    at com.yourkit.f.b.attach(a:188)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.yourkit.Main$5.run(a:17)

Attach to a running JVM failed.

Solution: start JVM with the profiler agent instead of attaching it to a running JVM:
https://www.yourkit.com/docs/java/help/running_with_profiler.jsp
root@remote-worker:/home/joe/yjp-2016.02/bin# 

Solution

  • Solution is printed at the end of message: start JVM with the profiler agent instead of attaching it to a running JVM: https://www.yourkit.com/docs/java/help/running_with_profiler.jsp

    Attach works only in HotSpot JVM; and running JVM process should have enough permissions. Please find details in "The attach mode limitations" at https://www.yourkit.com/docs/java/help/attach_agent.jsp