How do I debug my web project in Tomcat from Eclipse?
Author: Deron Eriksson
Description: This Java tutorial describes how to debug a web project in Eclipse without using plug-ins.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1 || Tomcat 5.5.20


Page: < 1 2 3 4

(Continued from page 3)

Next we need a Debug Configuration to let us fire up TomcatSW. Let's call it 'tomcat-demo'. The project obviously is 'tomcat-demo'. The Main class is 'org.apache.catalina.startup.Bootstrap', which you can find via the Search button with the 'Include libraries...' checkbox checked.

'tomcat-demo' Debug Configuration

On the arguments tab, set the working directory to your Tomcat directory, which in this case is C:\apache-tomcat-5.5.20. This is required for Tomcat to find the server.xml file that we just modified since server.xml is found relative to the Tomcat home.

Debug Configuration Arguments Tab

Now we can fire up Tomcat using our new tomcat-demo debug configuration.

Starting Debug Configuration for 'tomcat-demo' project

We can first try hitting test.html in our web directory in our project through Tomcat.

Hitting test.html via Tomcat in a web browser

Next, let's hit the TestServlet, which is mapped to 'test' in web.xmlW.

Hitting TestServlet

If you change your servletW output and refresh the browser, you will see your changes appear. The same situation applies for the files in your web directory.

If you update the path attribute in the context entry in server.xml to be something like 'hamburger', after stopping and starting Tomcat, this would mean that the URL that you would use to hit the test servlet in this project would be http://localhost:8080/hamburger/test.

This may seem like a long tutorial, but I think it's actually quite short in terms of what you actually need to do to get a project set up to run in Tomcat without any EclipseSW plugins. I included many screenshots since a lot of times with software configuration issues, 'A picture is worth a thousand words'. I couldn't really find any good examples of this Eclipse/Tomcat set-up on the web (although I imagine they exist somewhere), so I created this tutorial. I hope it helps your understanding of the way everything fits together. Feel free to try changing and tweaking things. A lot of times with software, you need to break something in order to actually figure out how it really works. Good luck!

Page: < 1 2 3 4