ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Hatton" <>
Subject <exec> called from a nested Ant session started with <java> - not terminating?
Date Wed, 10 Oct 2007 15:10:49 GMT

Versions: Ant 1.6.2 and 1.6.5, Java 1.5.0_05.

I have an Ant script that needs to call an Ant target with a different
environment (specifically with a different -lib setting) so I use <java>
to run this in a separate process as follows (the -lib is removed from
the arg sections here because the problem occurs even without it):

<java failonerror="true" fork="true"
  <env key="PATH" path="${java.library.path}"/>
  <jvmarg value="-Dant.home=${ant.home}"/>
  <arg value="-f"/>
  <arg value="start_weblogic.xml"/>
  <!-- -lib setting omitted -->
    <pathelement path="${ant.home}/lib/ant-launcher.jar"/>
<echo>java has terminated</echo>

Now, the start_weblogic.xml build script runs another process with an
<exec> task with spawn="true", so that it should outlive the Ant script.
Here's the target:

  <target name="wls-start-server">     
    <echo message="Start Weblogic Application Server"/>
    <exec spawn="true" dir="${wls-domain-dir}" executable="cmd.exe"
os="Windows 2000,Windows 2003,Windows XP">
      <arg line="/c startWebLogic.cmd"/>

    <waitfor maxwait="5" maxwaitunit="minute" checkevery="20000"
      <http url="http://localhost:7001/console"/>
    <echo>WLS has started</echo>

Now, if I run start_weblogic.xml directly from the command line, with
the appropriate -lib settings etc., all is well, the script runs and
starts the server, leaving it running after the script has completed.

However, if I call the start_weblogic.xml script indirectly, from my
other script using the <java> task, it starts the server, I see the
<echo> message "WLS has started", and the BUILD SUCCESSFUL message.
However, the <java> task does not appear to terminate until the other
process (started with spawn="true" from a forked JVM) has been
terminated. Only then do I see the <echo> message "java has terminated"
from the first fragment.  It appears that the nested Ant script has
completed, but the outer <java> task doesn't shut down. Interestingly,
the extra java.exe for the nested Ant script disappears from the Windows
Task Manager at the same time as the BUILD SUCCESSFUL message, so it
seems that the outer Ant script running the <java> task hasn't detected
this somehow.

Incidentally, the behaviour is identical if I use the <forget> task from
Ant-Contrib instead of the spawn="true" attribute.

Can anyone suggest what is going wrong here?


Axiom Systems Limited is a limited company registered in England and
Wales. Registered number: 2358771. Registered office: One Forbury
Square, The Forbury, Reading, Berks RG1 3EB

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message