I’ve been using both eclipse and tomcat for years but have always deployed my web apps externally and never had a problem. Now I’d like to use eclipse to debug my web app and I can’t figure out how to make it work. I started by trying to get my existing web app to deploy through eclipse but after hours of trying different things I decided to start fresh. Unfortunately, I didn’t get much further. I’m hoping if I can figure out how things work with a fresh webapp I can get things to work on my existing. Sorry, this will be long, but here are the steps I tried on the latest eclipse (Juno):
-
Installed new version of tomcat 7.0.34 at /usr/java.
-
In eclipse, used “servers” view to add server, pointing to the new install (I didn’t add any resources because there weren’t any available yet). Starting the server worked and got a 404 as expected at
http://localhost:8080/… then I stopped it. -
Created a new “dynamic web project”, named it TomcatDebug, set the location to ~/tomcat-debug, chose the server just created above (the only one), chose default config, tomcat-debug is empty so chose defaults for build paths, defaults for module settings and had it generate web.xml.
-
In the “tomcat-debug” folder it creates WebContent, build, and src. I throw a sample “hello, world” index.html into WebContent.
-
Now the project TomcatDebug is created so I try to run it, tell it to “run on server”, and it goes to
http://localhost:8080/TomcatDebug/but gives a 404. I even try to add index.html but it still gives a 404.
This is about as basic as it can possibly get so what did I do wrong?
Continuing to try and figure this out I stop the server, change the server setting to “use tomcat installation”, but still get a 404 in the same way when I restart. I tried changing my module context path and still 404.
I’m completely stumped. I believe I followed all the wizards as basically as possible. Where did I go wrong?
Thanks for taking a look.
I haven’t run tomcat through eclipse in a while, so can’t answer that aspect of the question. But, to get at the heart of what you’re trying to do (debug a webapp in eclipse through tomcat), you shouldn’t necessarily need to. This may serve you instead:
EDIT: Eh, look here for instructions (“Debugging” section). The below is how I did it (JUNO and TC 7) and has an annoying quirk in point #1.
edit the startup.sh (assuming *NIX/OS X) – the last line will probably be
exec "$PRGDIR"/"$EXECUTABLE" start "$@"change this to
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@"to activate debugging. (there are other ways to do this that may be better – i think tomcat/the VM may pause for listeners before proceeding, so when you aren’t debugging this is not ideal)
Create a Debug Configuration in eclipse, under the “Remote Java Application” set. Default port should be fine, and presumably host. Choose your project.
Add sources of relevance to your debugging in the Source tab.
Start server and run your new debug configuration. App should stop at breakpoints you’ve set.