![]() |
JSwat ProjectHow To: Debug Servlets |
The most important aspect in debugging Java servlets using JSwat is how you start the application server. The application server must be started with the debugging flags passed to the server JVM. These flags are similar to those used for remote debugging.
% java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n <appserver-mainclass>
As with remote debugging, you must launch JSwat and use the "Attach to Remote" item in the "Session" menu to attach to the running application server.
Scott U. reports the following about using Apache JServ with JSwat.
Anyway, the workaround is to tell Apache to start JServ in *manual* mode. This is done by setting the ApJServManual option to "on" inmod_jserv.conf
. Then, I can start the JServ process myself by just doing 'java org.apache.jserv.JServ jserv.properties
'. The beauty of this is that, since I am starting the Java process myself, I can just as easily start it from JSwat as well, with 'java com.bluemarsh.jswat.Main org.apache.jserv.JServ jserv.properties
'.
Debugging Jakarta Tomcat (
http://jakarta.apache.org/tomcat/), and the servlets it
serves, could not be any easier. Simply set the environment
variable TOMCAT_OPTS
to contain the following options,
and start Tomcat as you normally would (usually with the startup
shell script or batch file).
TOMCAT_OPTS = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n"
Then start JSwat and attach to the remote debuggee at the address displayed during the startup of Tomcat. The address may be surrounded by Tomcat's startup messages, so look carefully for it.