Debug a Java application in the Cloud

Introduction

Developing Java Applications will mean at some point doing some memory management and memory leak troubleshooting. This does not imply that Java is bad or worst than any other programming language, but we need to be prepared to do this type of testing if the need arise. The cloud has been in many ways a benefit for all start ups and Proof of Concepts developers, at the same time is a benefit it introduce some difficulties if you compare the same practices that were developing in your own home computer. In this writers area, you will find some notes on how to enable java console within a Cloud instance in Amazon EC2.

Assumptions

Knowledge in Amazon EC2
How to start/stop Instance.
How to Modify security Groups.

VNC
How to install VNC Server in Red Hat or your favorite flavor of Linux.

Steps to Setup JConsole to troubleshoot in a cloud Server

Since we are using a local jconsole session JAVA_HOME/bin/jconsole then start your java application with the following options:

export JAVA_OPTS=”-Djava.awt.headless=true -server -Xms###m -Xmx###m -Dbuild.compiler.emacs=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false”

Please substitute the ### in Xms and Xmx with in the Initial heap size and maximum heap size in megabytes, respectively. The port that you will use to connect to jconsole is port 4999, and both authentication and ssl are set to false since you are using local jconsole.

This is taken directly from the Java Sun web site.

Local monitoring with jconsole is useful for development and prototyping. Using jconsole locally is not recommended for production environments, because jconsole itself consumes significant system resources. Rather, use jconsole on a remote system to isolate it from the platform being monitored.

For now we are going to do local monitoring, not because is easier, since in reality it is harder in the cloud to do local monitoring, just because you have to install software on your instance that are not installed by default and is not local for you eitherway.

S
teps:

  1. Install VNC server on your Linux machin, if you have are using redhat a simple up2date install vnc-server” command.
  2. Make sure to open the Security Group in your cloud instance to port 5901, this is the default port for VNC Server.
  3. Now make sure you start the vnc service by typing in your console, vncserver :1
  4. Your java application is started with the options listed above, remember your jconsole port is 4999 or whatever number you entered there.
  5. Since the authentication option is set to false then you are going to be required to login locally and that is why we are installing vncserver.
  6. Now from any computer, using vnc-viewer type the ip address of your server followed with the colon “:” and the number entered in step 3.

  7. After you are login you will receive a super simple XTerminal.
  8. Left click and choose terminal window. From there go to the bin directory inside your java directory usually JAVA_HOME/bin/ and type “./jconsole &“.

Please watch the video below. It is a step by step copy of the steps 6-8. That way you will know if you are doing something wrong in any of those steps.

http://www.youtube.com/get_player

If you find errors or have any comments, feel free to leave them and I will incorporate into the text. Thanks again.

Tags: , , ,

2 Responses to “Debug a Java application in the Cloud”

  1. Digital Photography February 22, 2011 at 1:35 am #

    This was actually an interesting topic, I am very fortunate to have the ability to come to your weblog and I will bookmark this web page so that I may come again one other time.

  2. Ilse March 2, 2011 at 6:55 pm #

    Hi,

    This news item is captivating, continue like that. I add you to my favorites =)

    Best Regards

Leave a Reply