Saturday 8 September 2012

Set up Remote Debugging in Tomcat

Debugging tomcat can be a little but of a pain especially when it is a remote server.
So a quick solution is to use a remote debug option.
A good article on this can be found here (http://en.newinstance.it/2005/10/04/remote-debugging-tomcat-with-eclipse/).
But to add to this information I created a batch file called "runDebug.bat" in the tomcat/bin folder.

The file is:

set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=5050
catalina jpda start

Adding process monitoring

Having set that up you may want to use JConsole to monitor the process.
JConsole comes with the JDK and can be found lurking in the bin folder of your Java installation. 

To enable it with Tomcat you need to mmend your batch file as follows:

set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=5050
set JXM_PORT=5636
set CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=%JXM_PORT% -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.hostname=%COMPUTERNAME%/%JXM_PORT%

(NB. Make sure the CATALINA_OPTS is on one line).

A usefull reference on JConsole can be found here (http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html)
 
The next thing you will want to do is add some MBeans to your project. Which can be handled via Annotations.


No comments:

Post a Comment