You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Greg Roll <gr...@ServiceIntelligence.com> on 2002/11/19 21:32:34 UTC

Build hangs when attempting to start / stop tomcat.

I recently upgrade my JDK to JDK1.4.1_01 (from 1.4.0_03).  My previously
functional build.xml script for building projects now seems to hang when it
attempts to re-start tomcat.  I find it strange as this script function
properly when I am linked to the previous version of java.... in any
case.... I need to figure out to get the 'deploy' target to function
properly.  It has 3 depends 1) 'preDeploy' which shuts down tomcat 2)
'deployWebApp' to build and distribute the war file 3) 'postDeploy' to
restart tomcat.
 
Everything appears to work up to the part that postDeploy calls exec on
startup.sh... then the script just hangs until tomcat is shutdown from
another xterm.  I've tried different scenarios to attempt to get the process
to run in the background but to no avail.  Can anyone shed some light as to
what I'm doing wrong / and maybe why this isn't working under the latest
version of the JDK?!???
 
Cheers,
Greg Roll
 
 
Sample build file below:
 
<project name="cems" default="dist" basedir=".">
 
    <!-- set global properties for this build -->
    <property name="tomcat" value="/opt/tomcat" /> 
    <property name="strutslib" value="/opt/struts/lib" />
    <property name="javalib" value="/opt/javalib" />
    <property name="javabase" value="/opt/si/java/src" />
    <property name="proj" value="cems" />
    <property name="module" value="${javabase}/${proj}" /> 
    <property name="src" value="${javabase}/common" />
    <property name="build" value="${module}/build" />
    <property name="dist" value="${module}/dist" />
    <property name="docs" value="${module}/docs" />
    <!-- end global properties -->
      
    <target name="init">
       <!-- Create the time stamp -->
       <tstamp/>
       <!-- Create the build directory structure used by compile -->
       <!-- We attempt to re-create directories in src tree in case they
were empty! -->
       <mkdir dir="${module}/applets" />
       <mkdir dir="${module}/web/WEB-INF/lib" />
       <mkdir dir="${module}/web/WEB-INF/classes" />
       <mkdir dir="${build}/lib" />
       <mkdir dir="${build}/WEB-INF/lib" /><!-- for the jars and existing
lib stuff-->
       <mkdir dir="${build}/WEB-INF/classes" /><!-- app/webinf/classes -->
       <mkdir dir="${dist}/WEB-INF/lib" />
       <mkdir dir="${dist}/WEB-INF/classes" />
       <mkdir dir="${docs}" />
    </target>
 
   <target name="javadoc" depends="init">
      <javadoc packagenames="com.serviceintelligence.cems.*"
               sourcepath="${src}" 
               destdir="${docs}"
               author="true"
               version="true" 
               />
    </target>
 
    <!-- Populate the 'build' directories -->
    <target name="compileSrc" depends="init">
        <echo message="Building [cems] module..."/>
    </target>
 
    <target name="jarSrc" depends="compileSrc">
        <copy file="${strutslib}/struts.jar"
todir="${module}/web/WEB-INF/lib" /> 
        <copy todir="${build}/WEB-INF">
            <fileset dir="${module}/web/WEB-INF"
includes="*.tld,*.xml,*.properties" excludes="lib/,classes/"/>
        </copy>
        <javac
classpath="${build}/lib;${build}/WEB-INF/lib/struts.jar;${tomcat}/common/lib
/servlet.jar"
                srcdir="${module}/web/WEB-INF/classes" 
                destdir="${build}/WEB-INF/classes" />   
    </target>
 
    <!-- Compile the servlet code and copy static content-->
    <target name="compile" depends="compileSrc">
        <copy todir="${build}/WEB-INF">
            <fileset dir="${module}/web/WEB-INF"
includes="*.tld,*.xml,*.properties" excludes="lib/,classes/"/>
        </copy>
        <javac
classpath="${build}/lib;${build}/WEB-INF/lib/struts.jar;${tomcat}/common/lib
/servlet.jar"
                srcdir="${module}/web/WEB-INF/classes" 
                destdir="${build}/WEB-INF/classes" />     
    </target>
    
    <!-- Bundle WAR and distribute to webapps directory -->
    <target name="dist" depends="compile, jarSrc">
      <delete file="${dist}/*.war" />
      <copy file="${strutslib}/struts.jar" todir="${dist}/WEB-INF/lib" />
      <copy todir="${build}/WEB-INF">
        <fileset dir="${strutslib}" includes="*.tld" />
      </copy>   
       
      <war warfile="${dist}/${proj}-${DSTAMP}.war"
webxml="${module}/web/WEB-INF/web.xml">
        <lib dir="${dist}/WEB-INF/lib" />
        <classes dir="${build}/WEB-INF/classes" />
        <webinf dir="${build}/WEB-INF" excludes="classes/,lib/,web.xml" />
        <fileset dir="${module}/web" includes="*.jsp,*.jspp"
excludes="WEB-INF/, applets/"/>
      </war> 
    </target>
 
    <target name="clean">
      <delete dir="${dist}" />
      <delete dir="${build}" />
      <delete dir="${docs}" />
    </target>
 
    <target name="preDeploy">
      <echo message="Stopping Tomcat..."/>
      <exec executable="${tomcat}/bin/shutdown.sh"
            failonerror="false"/>    
      <sleep seconds="3"/>            
    </target>
            
    <target name="deployWebApp" depends="clean, dist">
      <copy file="${dist}/${proj}-${DSTAMP}.war" 
            tofile="${tomcat}/webapps/${proj}.war"/>
      <unwar src="${tomcat}/webapps/${proj}.war" 
             dest="${tomcat}/webapps/${proj}" />
      <sleep seconds="5"/>   
    </target>    
 
    <target name="postDeploy">
        <echo message="Starting Tomcat..."/>
      <exec executable="${tomcat}/bin/startup.sh"
            failonerror="true" />
      <sleep seconds="15"/>    
    </target> 
 
    <target name="prep_cems" depends="deployWebApp" />   
    
    <target name="deploy_cems" depends="preDeploy, prep_cems, postDeploy" />
    
    <target name="deploy" depends="clean, deploy_cems">
    </target> 
 
    ....
 
</project>