Fei Qu
Fei Qu

Reputation: 979

use eclipse to debug tomcat web app

As the title says, I want to debug web app in tomcat by eclipse. I followed these instructions:http://www.wikijava.org/wiki/Debugging_a_servlet_with_tomcat_and_Eclipse_tutorial Basically, what I did is setting the JPDA and starting the server out of eclipse. Then I connected eclipse debugger to the server. However, when I tried to access the webpage from browser, I got a 404 error. I ran tomcat in eclipse before(non-debug mode) and I can get the webpage.

So my guess is it's because my workspace is not the webapp folder in tomcat. (I follow this webpage to install tomcat and eclipse http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html) If I run tomcat out of the eclipse, it'll try to search the request inside tomcat's webapp folder and can't find it. So can I solve this problem just by setting my eclipse workspace to webapp folder in tomcat? I don't think it'll work because the file system structure in webapp of tomcat is quite different from file system structure of the dynamic web project of eclipse.

Any suggestions?

Upvotes: 3

Views: 7470

Answers (2)

Oleksii Dz
Oleksii Dz

Reputation: 71

If you've already configured Tomcat server which starts from Eclipse. You have to open Servers, then by click right mouse button open Properties. In opened new window choose Monitoring and just click Add button (with parameters HTTP/1.1, there should be port in which starts web server, and Monitor port whatever you want). Then just put breakpoints and start your project in debugging mode. Everything should be works.

check printscreen here

Upvotes: 2

Zagrev
Zagrev

Reputation: 2020

I don't know what version of Eclipse you are using, but this is the simplest way.

  1. install Web Tools for Eclipse http://www.eclipse.org/webtools/
  2. Create a Server for Tomcat (File / New / Other ... -> Server / Server).

This integrates Tomcat into you development environment. Projects auto-deploy, code is automatically available in the debugger. It's just so easy. And free. Don't wait.

Upvotes: 1

Related Questions