JVM remote debugging can be sometime tricky and elusive — especially when the process is running as a service. How can you separate JVM issues from other factors such as process running as service as a different user, firewall blocking debug port. One way to separate these is to know a bulletproof configuration for JVM remote debugging. Without further ado, here it is:
Note that this only applies to Java 5 and above. If you are still in stone ages, hopefully you are not reading this blog either. This is great but how can I test it quickly? I still can’t connect. My server runs headless Linux environment, and I don’t have access to my pretty IDE. One method to use telnet.
telnet silly.example.com 5005
It works but there is something better. Command line
jdb and its little known use to connect to remote process. You can also use it do debugging if you like.
/usr/java/current/bin/jdb -connect com.sun.jdi.SocketAttach:hostname=silly.example.com,port=5005
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb …