How do I debug a Dynamic Web Project using the Tomcat bootstrap?
Author: Deron Eriksson
Description: This tutorial describes how to use the Tomcat bootstrap jar to debug an Eclipse dynamic web project
Tutorial created using: Windows XP || JDK 1.6.0_02 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0) || Tomcat 5.5.20


Page: < 1 2 3

(Continued from page 2)

For testing purposes, I'll add a 'Howdy' message from the doGet() method of TestServlet.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	response.getWriter().println("Howdy");
}  	

We'll need to add a Context entry to Tomcat's server.xml to tell TomcatSW the project's docBase and the URL path that should be used to access to project.


<Context docBase="C:\projects\workspace\dynamic-web-test\WebContent" path="/dynamic-web-test" reloadable="true"/>

I'll create a Debug Configuration for the 'dynamic-web-test' project, specifying that org.apache.catalina.startup.Bootstrap is the main class (this is contained in the Tomcat bootstrap.jar file).

Debug Configuration

We can set the Working directory to be the home directory of our Tomcat installation.

Debug Configuration Arguments Tab

If we fire up our project in the Debug Configuration that we just created and then try hitting TestServlet in a web browser, you can see that we indeed can hit the servletW, since we are greeted by the 'Howdy' message.

Hitting TestServlet in web browser

In conclusion, it is quite easy to set up a Tomcat bootstrap debug configuration to run a Dynamic Web Project in EclipseSW. This technique is slightly more involved than setting up a Server configuration in Eclipse to run your project, but it is on the whole quite simple. Although features such as setting breakpoints in jsp's may not work if you run your project using the bootstrap method, working on your project on standard development tasks will typically be much smoother using the Tomcat Bootstrap class. The Server configuration is nice in terms of being able to click a couple times to run a web application, but it hides some project configuration details which can be annoying when you're trying to resolve difficult issues. The Bootstrap debug configuration technique covered in this tutorial exposes more details, which can simplify your debugging efforts. I recommend giving it a try. You may find that one technique works better for a particular task, and at other times, the other technique works better.

Page: < 1 2 3