Friday, July 30, 2010

Eclipse - Debug Web Application running on Tomcat/JBoss

How to debug a web application, running on Tomcat/JBoss server, in Eclipse ?

Here are the simple steps to follow:

Tomcat

[1] create new batch file along side "catalina.bat" file, paste following code, save and run:

set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
catalina.bat jpda start

[2] Start eclipse -> Run menu -> debug configuration -> Remote Java Application -> New launch configuration -> Make sure port is 8000 in connection properties.



JBoss

[1] Edit the run.bat file of JBoss to use the following debug options (note the suspend=n option, this tells the server not to wait till the debugger attaches itself to the server

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%

2) Start the server from the command line, using the run.bat file.

3) Once the server has completely started, i go to my (plain) Eclipse project and create a new "Remote Java Application" debug session (if it's not already created). In the "Port" text box i specify 8787 (the same as what i have in the run.bat). Then click on Debug.

The steps will be the same for NetBeans too (expect for the part where you have to configure NetBeans to listen to the debug port).

No comments: