Paul Gu | Blog

sharing is caring

Setting Up Tomcat For Remote Debugging

To configure tomcat to allow remote debugging, start tomcat using the catalina startup script (from your tomcat home) instead of the normal startup script like so (tomcat must be stopped before you can change over):

WIN:

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

UNIX:

export JPDA_ADDRESS=8000
export JPDA_TRANSPORT=dt_socket
bin/catalina.sh jpda start

We recommend adding this stuff to your startup script so that you are always running tomcat in debug mode.

Open the startup script in (your_tomcat_home)/bin (WIN: startup.bat, UNIX: startup.sh)

Add the following lines at the first blank line in the file (around line 8)

WIN:

set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket

UNIX:

export JPDA_ADDRESS=8000
export JPDA_TRANSPORT=dt_socket

Change the execute line at the end to include jpda start

WIN:

call “%EXECUTABLE%” jpda start %CMD_LINE_ARGS%

UNIX:

exec “$PRGDIR”/”$EXECUTABLE” jpda start “$@”

Run the startup script when starting tomcat to run tomcat in debug mode

Once you have tomcat configured and started, you can connect to your running tomcat instance using a number of debugging tools. For example, Eclipse has a debugging view that can help you work with tomcat via remote control.

Note

If you are using Eclipse to debug tomcat remotely so in a Windows environment, you may want to prevent tomcat from launching as a separate process, which will prevent the console output from being captured by the Eclipse debugging view. To do so edit the file TOMCAT_HOME/bin/catalina.bat and change:

Original:

:doStart
shift
if not “%OS%” == “Windows_NT” goto noTitle
set _EXECJAVA=start “Tomcat” %_RUNJAVA%
goto gotTitle
:noTitle
set _EXECJAVA=start %_RUNJAVA%

New:

:doStart
shift
if not “%OS%” == “Windows_NT” goto noTitle
set _EXECJAVA= %_RUNJAVA%
goto gotTitle
:noTitle

set _EXECJAVA= %_RUNJAVA%

Next Post

Previous Post

Leave a Reply

© 2024 Paul Gu | Blog

Theme by Anders Norén