debugging java application deployed in tomcat
yes, you need to configure tomcat to accept remote debugging connections. There is a FAQ on how to do it with various IDEs.
http://wiki.apache.org/tomcat/FAQ/Developing#Q2
- Create a new tomcat server
- Create a new dynamic web project
Export war to tomcat server
- Tomcat debug configuration(important), first double click tomcat server, then select "Use Tomcat installation (takes control of Tomcat installation)"
- Add breakpoints
- Run tomcat in debug mode
- Test war in web browser
- Edit source path
- Debug source code in Tomcat
The war file is available here.
First, you need to run Tomcat in debugging mode. The easiest way to do that is to modify the startup file (.bat or .sh depending if you are Windows or not). Find the line near or at the end of the file that contains the start
command, and change it to jpda start
. This will cause Tomcat to start in debugging mode listening on port 8000
.
Next, to connect to this process via Eclipse, select the Run
menu and choose Debug Configurations...
. In the pane on the left, choose Remote Java Application
and click the New launch configuration
button above the list. The important settings to note are the Host
and Port
fields. The host value must match the hostname of the Tomcat process, and the port should be 8000
. You also might need to add entries on the Source
tab to ensure that all of the source code is available to step through.
Simply change the line in startup.bat
(if you are using Windows)
from:
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
to:
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%