I wrote this up once in a forum post on dslreports and recently someone asked me about that again... I've been working on a *better* and more encompassing (ie: not just tomcat) write up to post somewhere on my web page, but for now, to preserve it for posterity, here's what I posted on dslr a long time ago..
JDB is the debugger that comes with Sun's JDK.
It's very important to use at least version 1.3.0 of JDK, otherwise the debugger is rather flaky and tends to core dump.
1. Start tomcat with these options:
-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:server=y,
transport=dt_socket,address=8000,suspend=y
8000 can be replaced by any other numerical value.. it basicaly tells jvm to listen on that port for a debugger.
What will happen now, is tomcat will start but suspend itself and wait for a debugger to attach before proceeding.
2. start JDB and attach:
jdb -attach localhost:8000
in here, localhost can be replaced by where tomcat is running if it's running on a different machine and 8000 can be replaced with whatever port you set jvm in tomcat.
Voila! You can now debug servlets.
TrackBack URL for this entry: http://www.unix-girl.com/mt/mt-tb.cgi/16