I use ant script to create a war file of my application. Is there a way to debug my application in eclipse?
-
possible duplicate of [Debug my web application using ant](http://stackoverflow.com/questions/8423795/debug-my-web-application-using-ant) – CoolBeans Dec 15 '11 at 19:34
-
or a duplicate of [Any way to debug web application using Eclipse?](http://stackoverflow.com/questions/5374849/any-way-to-debug-web-application-using-eclipse) – CoolBeans Dec 15 '11 at 19:35
-
how building with Ant is related to debugging from Eclipse? – Oleg Mikheev Dec 15 '11 at 19:46
-
I dont understand what do they mean by adding the line's in the startup command... Can someone explain me in steps how to add the lines in start up command? – Ahmed Dec 16 '11 at 18:34
2 Answers
If you are using tomcat server. Install Mongrel plug-in to your eclipse. After building ant script, just add break points to code and click on tomcat start button provided by Mongrel plug-in. Your app will be automatically running in debug mode. And Mongrel(Tomcat) automatically deploys your war file.
I am currently using the same for my projects.

- 16,024
- 8
- 58
- 85
-
My war file which is created through ant script is in deploy folder... Now the problem is it doesn't get that war file. – Ahmed Dec 16 '11 at 20:12
If you have all the source code in Eclipse and merely use the ant script for building, you should be able to do debugging by just putting the generated war in the deploy folder of your server (or doing whatever else your server requires to deploy a war), and then simply start up your server via Eclipse.
Eclipse wouldn't 'know' that anything has been deployed to the server it has just started, but the connection between WTP's deployer and JDT's debugger is pretty weak anyway. It will simply try to match classes in the JVM to Java files in your workspace. If you have the actual source there this will of course match and you can debug.

- 37,782
- 12
- 108
- 140
-
Well that's kind of nice way to get it... But then if we start our server from eclipse how can I set the variables with the startup command? Cause I have a single variable that needs to be set on start up command. Is there a way can you please explain that to me? – Ahmed Dec 16 '11 at 23:06
-
Yeah that's easy, double click your WTP server in servers view, go to `Open launch configuration` enter your startup variables under 'VM arguments'. – Arjan Tijms Dec 16 '11 at 23:50
-
Two simple solutions, maybe the first is a bit silly but it's just "Don't start the server from the command line" ;) If you already have Eclipse up and running for debugging, why not just use that anyway? The second is starting via command line in debug mode and then attach Eclipse to it via its remote debugging feature. – Arjan Tijms Dec 19 '11 at 22:33