Wednesday, March 28, 2007

Debugging tomcat applications using IDE's

Problem:
You have deployed your war file into tomcat. You have the source code, but you cannot innitate a DEBUG from the IDE(Eclipse or Netbeans). How does one debug?

Solution:
Run tomcat in DEBUG mode

WINDOWS
EDIT %CATALINA_HOME%/bin/catalina.bat
set JAVA_OPTS=-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=3091,suspend=n

UNIX

EDIT $CATALINA_HOME/bin/catalina.sh
JAVA_OPTS=-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=3091,suspend=n

Restarting tomcat will render it in debug mode listening on port 3091.

Now in your favourite IDE have the REMOTE DEBUGGING listening on port 3091.
Then the course is normal, place breakpoints in your code and trace for possible bugs.

No comments: