Assumptions
Local tomcat instance on machine
Eclipse installed on machine
Ability to deploy and run webapps on local tomcat instance
Steps
1. Start tomcat in debug mode
Command Line
Navigate to [tomcat_base]/bin
Run command:
catalina jpda start
*This will start the debug server listening on port
8000. If 8000 is unavailable you can specify with extra arguments. See
attached document 1.
Windows Service
Add the following lines to Java Options under
Configure Tomcat - Java tab
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
2. Create Debug configuration in Eclipse
Run -> Debug Configurations...
1. Select the project you want to debug. If you want to
debug any dependencies of that project you will need to ensure the source code
for that project is imported into eclipse.
2. Ensure Standard (Socket Attach) is selected
3. Enter host location
4. Enter Port. Default from above steps is 8000.
3. Attach Debugger to running instance of Tomcat
4. Create desired breakpoints and open Debug Perspective of
Eclipse
Create
breakpoints by either double clicking, or rightclick ->toggle
breakpoint of left margine of source code.
Open
debug perspective from Window-> Open Perspective -> Debug
Debug Perspective
Shows
that Eclipse is currently connected, you can see all running threads
Quick
button to open view
Hints:
Set
breakpoints by double-clicking the left margin of Eclipse editor, or by
rightclicking the margin -> toggle breakpoint.
Clear
breakpoints after making changes, this avoids 'ghost breakpoints'
(there is a clear all button in debug perspective -> breakpoints tab).
Ensure
that the code you are debugging on the server is up-to-date with what is
in your editor.
Extra Documentation