This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

debugging with ANT

 
Peter Primrose
Ranch Hand
Posts: 755
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Primrose
Ranch Hand
Posts: 755
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 755
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 755
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 755
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
right! I had it running twice.

what does this error mean?

 
Matt Harrah
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 755
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 755
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :-)

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic