Wednesday, September 27, 2006

Remote debugging with Eclipse and Tomcat 5

I recently tried to setup remote debugging on Eclipse 3.2, JSDK 5.x and, & Tomcat 5.x
After spending about 4 hours playing with $catalina_home$/bin/startup.bat, and $catalina_home$/bin/catalina.bat I came up with this one line solutions.

Create a setenv.bat file in the $catalina_home$/bin/ folder.
add the following line to the above file.

set JAVA_OPTS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5000

run using $catalina_home$/bin/start.bat and you should see the first line in your new tomcat window read the following.

Listening for transport dt_socket at address: 5000

Now you are ready to go into Eclipse and choose Run-->debug... -> From the left panel choose "Remote Java Application" then in the same dialog box click on the icon "new launch configuration". This is the first icon on top of the left panel.
On the upcoming dialog box, Give this config any name then add the following two pieces of info in the same dialog box

set the server name: localhost or IP of the remote server
set the port number to be 5000

That's it.

Now set up breakpoints in your code and enjoy the Eclipse debugger stop at the breakpoints while your run the app from the browser.


Dr. Java