In a previous blog, here, I wrote on how you can use
jstatd to enable remote profiling.
jstatd route is convenient: you don’t have to change the startup scripts of your application. However, in some cases I actually have VisualVM freezing on me, or at least taking ages to start, longer than I care to wait. Also, not all features of
VisualVM will be enabled.
For example, you want to take a CPU snapshot and you get a message like this:
As the message suggest, you’ll need to enable JMX. Unfortunately, this can only be done at startup by adding some parameters:
java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=1098 -jar BattleBugs.jar server -localhost
Again, similar as with running
jstatd, you might end up with JMX binding to a wrong IP address. Telling the JVM explicitly on where to bind to will help:
If the firewall Gods are in a good mood, you’ll see this: