wood burning stoves*
The moose likes Ant, Maven and Other Build Tools and the fly likes spawning a server in ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "spawning a server in ant" Watch "spawning a server in ant" New topic
Author

spawning a server in ant

Stephen Bloch
Ranch Hand

Joined: Aug 19, 2003
Posts: 48
I'm trying to write a client/server program, and to test it I need to start the server, leave it running, and then run the client. Is there a way to do both of these from within an ant task? Everything I've tried results in ant waiting for the server to terminate before it goes on to the next subtask, which is running the client.

So what have I tried?
1)

This produces the error message "The <java> task does not support the spawn attribute," directly contradicting the ant documentation. See
this thread.
2) <exec executable="${basedir}/serverd"/>
where "serverd" is a shell script looking like


This successfully starts the server, but ant never gets past it to do anything else.


SCJP 1.4
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
What version of Ant are you using? (You find out by running "ant -version".)


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Stephen Bloch
Ranch Hand

Joined: Aug 19, 2003
Posts: 48
When I type "ant -version" at the command line, I get 1.6.2, dated July 16, 2004, but I think Eclipse is using a 1.5.3 plugin. Where can I get an updated plugin?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Well, I'm rather sure that Eclipse 3 uses Ant 1.6.2.
praveen
Greenhorn

Joined: Jun 23, 2003
Posts: 4
Yeah,
You better to run two executables in the shell script in sequence.
i.e, 1. Server application.


<exec program="${bash.exe}" commandline="./updateBuild.sh"/>
praveen
Greenhorn

Joined: Jun 23, 2003
Posts: 4
Yeah,
You better to run two executables in the shell script in sequence.
i.e, 1. Server application.
2. Client application.

<exec program="${bash.exe}" commandline="./shellscript.sh"/>

Hope, it'll solve your problem.

cheers,
praveen
Stephen Bloch
Ranch Hand

Joined: Aug 19, 2003
Posts: 48
I don't have Eclipse 3 yet, because I haven't upgraded my Mac to OS 10.3 yet, because 10.4 will be out any month now.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Stephen Bloch:
I don't have Eclipse 3 yet, because I haven't upgraded my Mac to OS 10.3 yet, because 10.4 will be out any month now.


OK, this explains it.

There should be an org.apache.ant folder in your eclipse plugins folder or something like that. Replace the ant.jar file in there with that of the version of ant you need. You might need to do something more for the optional tasks, but I don't remember how that worked prior Eclipse 3. Possibly you need to edit the plugin.xml or something...

Hope this helps...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spawning a server in ant
 
Similar Threads
using ant and emma on client/server app
Ant task to start/shutdown jboss
ant task for running two java classes in different jvms
Spawn for ant+linux
Build Failed