Remote debugging your jmx enabled process in the ec2 cloud via jconsole isn’t easy for any number of reasons. Perhaps it’s the NAT setup at AWS. Perhaps it’s Ubuntu or Linux related. The most common workarounds given are to have jconsole run on the remote box and either export its display locally via X (using, for example ssh -X or ssh -Y to tunnel) or via VNC. I found the former too slow and the latter too time consuming to set up on our existing systems.
However, I discovered nx, a set of technologies to greatly compress the X protocol, was very easy to set up on our Ubuntu boxes. It made the process of running jconsole remotely but displaying to my laptop locally very tolerable indeed. Not surprising as nx is intended to allow you to run xterm even over dialup! Here are the set of steps I followed (instructions derived from the nomachine site) to set up a nx enabled account on a remote Ubuntu Hardy Heron box. Your mileage may well vary.
On your remote box:
- install jconsole if you don’t have it. It’s in the Sun JDK package: apt-get install sun-java6-jdk
- Get the nx debian packages from nomachine:
- wget http://188.8.131.52/download/3.4.0/Linux/nxnode_3.4.0-6_i386.deb (64 bit: http://184.108.40.206/download/3.4.0/Linux/nxnode_3.4.0-13_x86_64.deb)
- wget http://220.127.116.11/download/3.4.0/Linux/nxclient_3.4.0-5_i386.deb (64 bit: http://18.104.22.168/download/3.4.0/Linux/nxclient_3.4.0-7_x86_64.deb)
- wget http://22.214.171.124/download/3.4.0/Linux/FE/nxserver_3.4.0-8_i386.deb (64 bit: http://126.96.36.199/download/3.4.0/Linux/FE/nxserver_3.4.0-12_x86_64.deb)
- Required by nxserver: apt-get install libaudiofile0
Install nx client, node, server:
dpkg -i nxclient_3.4.0-5_i386.deb
dpkg -i nxnode_3.4.0-6_i386.deb
- dpkg -i nxserver_3.4.0-8_i386.deb
- Create an nx enabled account called “nxtest”. You supply the account password.
- /usr/NX/bin/nxserver –useradd nxtest –system
- You might have to edit ~nxtest/.profile to add the “/usr/bin” to the PATH if it’s not added already.
- There are other and more secure ways of doing this.
- Install enough X libraries to get the remote desktop going. You can do various patchwork stuff but nx appearts to work best with KDE, so: sudo apt-get install kubuntu-desktop
On your local box:
- go to nomachine.com, download and install the free nx client for your PC type.
- start up the nx client
- give the remote hostname/ip address, provide a session name
- username: nxtest, password: <whatever password you used to set up the account>
- this should open a remote desktop with KDE running
- run “jconsole” as a separate command, use the remote option to connect to the java process.
That should do it!