Friday, December 14, 2012

Remote Debugging Tomcat with Eclipse

Tomcat should be started with debug options. This can be simply done by adding the jpda option when running as follows.
./ jpda start
When jpda option is provided catalina will set some default debug related options such as the debug port (default is 8000) and etc. User can change these values in the script if a custom behaviour is needed.

Then in Eclipse we should create a new debug configuration (Run -> Debug Configurations... in Indigo). Under the 'Remote Java Application' located in the menu to the left of the configuration pop-up, we should create the new configuration giving the Host (location of the remote server, this can be localhost also) and the debug Port that we set while starting Tomcat (default 8000). Also, an Eclipse project can be given where the sources needed for debugging is located.

Then, when we press 'Debug' and go to the 'Debug Perspective', we'll be able to see the Tomcat application getting remote debugged.

We'll be able to set breakpoints in the source, inspect values and utilize all the usual facilities we get when debugging inside Eclipse.

No comments: