I've configured my linux remote machine (with JRE 1.7) to execute the java application with the necessary properties for jmx:
java -Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=5005 \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar myapplication.jar
Now in my windows local machine (where I have JDK 1.7) I want to use the tool jmap, for example to print the histogram:
jmap -histo 10.218.72.227:5005
But it's faling with the following error:
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
Attaching to remote server 10.218.72.227:5005, please wait...
Error attaching to remote server: java.rmi.NotBoundException: Not bound: "SARemoteDebugger" (only bound name is "jmxrmi")
The weird thing is that I can connect using the jconsole successfully, but first it prompts me with a message to Retry the connection insecurely (without SSL):
Therefore, it seems like it should be some sort-of a flag for jmap in order to work, do you know how to overcome this problem?
Following the man page of jsadebugd - Serviceability Agent Debug Daemon you need first to attach it to your process to be able to use
jmap
remotely.The below steps show how it works.
The used Java version for all java processes (local and remote).
execute on remote host
java -jar myapplication.jar
rmiregistry
rmiregistry -J-Xbootclasspath/p:$JAVA_HOME/lib/sajdi.jar &
jps
(e.g.12345)jsadebugd 12345 42
execute on local host
jmap
jmap -heap [email protected]
output on local host
Additional notes: The man page states
This utility is unsupported and may or may not be available in future versions of the JDK
.Maybe running jmap on the remote machine (e.g. via ssh) would be a better approach.