Meaningless Drivel is fun!*
The moose likes Ant, Maven and Other Build Tools and the fly likes debugging with ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "debugging with ANT" Watch "debugging with ANT" New topic
Author

debugging with ANT

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Guys,

(newbie to ANT) I wonder if it is possible to debug a sturts application with ANT? is there any target I need to add to single tomcat that it's a debug mode

thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Some IDE's (such as Eclipse) have Ant debuggers. However these are for debugging the build itself. Using Ant to debug a Struts application though can't be done - Ant is not an IDE.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
I guess I�ve explained myself incorrectly:

Let me try again:

I'm using eclipse. I'm building a struts application. I'm using ANT to do all the compile,debug,deploy...

Now, say I want to check the flow of events when an Action is preformed - how can I do that?

I tried to place a breakpoint on that specific Action - and when running the application (with ant) the application did not stop at the breakpoint.

My question: how to stop the application at a specific breakpoint and look at the code.

Thanks
Anay Nayak
Greenhorn

Joined: Aug 15, 2006
Posts: 26
You first have to start tomcat in debug mode. Since you are using ant to start the server you will have to modify the build.xml file so that appropriate parameters are passed to tomcat during start up.

Search for the target in your build.xml and add the parameters
<target name="tomcat-start-debug">
<java jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
<jvmarg value="-Dcatalina.home=${tomcat.home}"/>
<jvmarg value="-Xdebug"/>
<jvmarg
value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"/>

</java>
</target>
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
mmmm....ok this is a good start.

how do you configure tomcat to run in debug mode (using tomcat 5.0)?

I get this message with Ant:



I notice my eclipse: window-prefnces-romcat-jvm settings is configured to jre1.5.0_06, isn't that J2SE 5.0???

I also set the project-prefrences-java build path-libraries to use jre1.5.0

Anay Nayak
Greenhorn

Joined: Aug 15, 2006
Posts: 26
I guess you are running the ant target directly from eclipse. In that case, select the target, in run menu select "Run..." and then in the JRE tab select the JVM you want to use.
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
thank you Anay. I'm getting there (almost)

few things:
1. Yes, I'm using eclipse.
2. I'm using Tomcat 5.5 - I have the small icon next to the clock and I set it as: Start Service (should I do it from eclipse ANT???)

When Runnnig ANT (now after fixing the problem with the J2SE5.0)
I get this message:

( i googled for 2hr the error: class file has wrong version 49.0, should be 48.0....still don't get it...I'm using 1.5 in the project??)


Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


java.net.BindException: Address already in use: JVM_Bind:8080

Looks like you can't run Tomcat from Ant because there is something else using a port it needs. I'd guess it is another instance of Tomcat you've forgotten to stop. Check to see if that is the case.
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
right! I had it running twice.

what does this error mean?

Matt Harrah
Ranch Hand

Joined: Aug 05, 2006
Posts: 54
Just curious --

If you're in Eclipse, why are you using Ant to start/stop Tomcat? Is that a requirement for your project?

Why don't you use the Servers view and define a Tomcat instance in that and use that to stop and start Tomcat? It's far easier and allows you to stop/start/restart it in either debug or normal mode on demand independantly of your Ant script.
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
no it's not a requirment. I don't stop/start tomcat. I redeploy.
What I'm trying to get here is deployment AND debugging.
I get the deployment well but not debugging.

I fixed the class file has wrong version 49.0, should be 48.0 with the ANT jars (from eclipse).

anyhow, the result of the ANT is below BUT I cann't debug


Anay Nayak
Greenhorn

Joined: Aug 15, 2006
Posts: 26
In your last log file i can see two errors

1) SEVERE: Parse Error at line 49 column 17: The content of element type "struts-config" must match

Your struts-config file has some errors. Remove those errors.

2) You are possibly running two instances again! I hope you are only using the ant script now...and not the "start service" button . The ant task only starts tomcat. It doesnt shut it down.
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
OK.............
This case is closes!!! THANK YOU ALL!!!
Yes, Anay, you were right...I realized that once again 2 inst where running. I also realized that some settings had to be done in ECLIPSE - tomcat section!

anyway Thanks again!!! it works....now the real job :-)

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: debugging with ANT
 
Similar Threads
ant junit
Ant - Javac Task attribute DEBUG
[newbie] ant don't show warning messages
Ant script debugging
Eclipse remote debugging: Unable to install a breakpoint error