cattails

Blue Marsh Softworks

 Site Index
 o java projects
 o about me
 o search

 My Java
 o java tips
 o java faq
 o contributing
 General Java
 o JavaSoft
 o Developer Connection
 o The Java FAQ
 o Java Glossary

 JSwat
 o download
 o documentation
 o faq
 o mail lists
 o contributing
 o bugs
 Related Software
 o JPDA
 o Emacs JDEE
 o JDBTool
 o jEdit plugin
 o Jenus
 o NetBeans
 Related Links
 o Top Ten Reasons Not to Use a Java Debugger in School

Servlet Debugging

Starting the Server

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. Note that many application servers have startup scripts that must be run to properly bootstrap the system. You may want to read these scripts to better understand how to enable remote debugging. Or, you can keep reading and maybe you will find instructions for your application server.

Apache JServ

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" in mod_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'.

Jakarta Tomcat

Debugging Jakarta Tomcat, and the servlets it serves, is very easy. Below are the instructions for debugging the two popular versions of Tomcat.

Version 3.3.x

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. Windows note: You can use the shared memory transport instead of the socket transport on Windows systems. Replace the dt_socket with dt_shmem and use the shared memory attach support in JSwat to connect to the name shown in the Tomcat console.

Version 4.0.x

This version of Tomcat has very good support for debugging via the JPDA. By default the catalina.sh Unix shell script will run the socket transport for remote debugging, on port 8000. The catalina.bat Windows batch file will use shared memory, with address "jdbconn". Both of these addresses can be changed by setting the JPDA_ADDRESS environment variable before starting Tomcat.

To start Tomcat with JPDA support, you must invoke the catalina.sh or catalina.bat with the arguments "jpda start". Attempting to use the startup command will fail because it will pass the arguments "start jpda start" to the catalina command and that will fail.

The above 4.0 information is courtesy of Paul E.

© Copyright 2000-2002 - Blue Marsh Softworks