Friday, March 7, 2008

Remote Debugging a Web Service using Eclipse and Tomcat

This is working with Tomcat 5.0.X, Eclipse 3.2, JDK 1.4.2_*

Step 1. Configure Tomcat
a) Open up the configuration GUI ("Configure Tomcat")
b) Select the Java tab
c) Into the Java Options include (substituting the correct locations)
-Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
-Dcatalina.home=c:\tomcat
-Djava.endorsed.dirs=c:\tomcat\common\endorsed
-Djava.io.tmpdir=c:\tomcat
NB: These are all on separate lines, with a at each EOL
d) Select the Startup tab
e) Into the Arguments section include:
jpda
start
NB: These are all on separate lines, with a at each EOL
f) Start and Stop Tomcat completely

2. Configure Eclipse
a) While in the Java perspective select "open Debug Dialog"
b) Choose "Remote Java Application" from the tree (right click/New)
c) The defaults are all that is required.
d) Click "Debug" in the bottom corner to start it now, or Close for later

3. Debugging the Application
a) Create a breakpoint in the code
b) Click on the "Debug" (if not already debugging) (*)
c) Click on the Debug Perspective (optional)


(*) If you get an error such as "Failed to connect to remote VM. Connection Refused". This normally means that Tomcat isn't started, _or_ there is already a debugging session started via jpda. Check Tomcat is running, and check the Debug perspective to make sure that it isn't running.

No comments: