I have a problem with the build process on a new server that I have setup just for development purposes.
This is running on a Centos 6 box with Java/Tomcat v7. The output is as follows:
Buildfile: /home/ec2-user/twv/trunk/EES/build.xml
init:
[echo] Build of EES started at 1332 on December 19 2015
clean:
[echo] Cleaning EES
[delete] Deleting directory /home/ec2-user/twv/trunk/EES/build
compile:
[echo] Compiling EES
[mkdir] Created dir: /home/ec2-user/twv/trunk/EES/build/WEB-INF/classes
[javac] Compiling 78 source files to /home/ec2-user/twv/trunk/EES/build/WEB-INF/classes
BUILD FAILED
/home/ec2-user/twv/trunk/EES/build.xml:118: /home/ec2-user/twv/trunk/EES/${currentenv.TOMCAT_HOME}/lib does not exist.
Other responses on SO suggest that the environment variable isn't created but If I run the following:
echo $TOMCAT_HOME
it returns:
/usr/local/tomcat7
So I know that the variable exists and is set.
This is the build.xml file:
<?xml version="1.0"?>
<!-- #######################################################################
B u i l d S c r i p t
####################################################################### -->
<project name="EES" default="war">
<description> EES </description>
<property environment="currentenv" />
<property name="tomcat.home" location="${currentenv.TOMCAT_HOME}"/>
<property file="build.${currentenv.ANT_HOST_NAME}" />
<property name="webapp.path" value="build"/>
<!-- #######################################################################
T a r g e t : I n i t
####################################################################### -->
<target name="init">
<tstamp/>
<echo>Build of ${ant.project.name} started at ${TSTAMP} on ${TODAY}</echo>
</target>
<!-- #######################################################################
T a r g e t : D e f a u l t
####################################################################### -->
<target name="war" depends="init, clean, compile,compilejsp,copywebroot" description="Bundle up everything">
<!-- target name="war" depends="init, clean,compile,copywebroot" description="Bundle up everything" -->
<echo>Packaging ${ant.project.name}</echo>
<jar destfile="EES.war" basedir="${webapp.path}"/>
<echo>Finished packaging ${ant.project.name}</echo>
</target>
<!-- #######################################################################
T a r g e t : C o p y w e b r o o t
####################################################################### -->
<target name="copywebroot">
<copy todir="${webapp.path}" >
<fileset dir="WebRoot">
<include name="**"/>
</fileset>
</copy>
</target>
<!-- #######################################################################
T a r g e t : j s p c
####################################################################### -->
<target name="jspc">
<taskdef classname="org.apache.jasper.JspC" name="jasper2" >
<classpath id="jspc.classpath">
<pathelement location="${java.home}/../lib/tools.jar"/>
<fileset dir="${tomcat.home}/bin">
<include name="*.jar"/>
</fileset>
<fileset dir="${tomcat.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${tomcat.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${ant.home}/lib">
<include name="ant.jar"/>
</fileset>
</classpath>
</taskdef>
<mkdir dir="${webapp.path}/WEB-INF/src"/>
<!-- <jasper2 verbose="255"
validateXml="false"
uriroot="${webapp.path}"
webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
outputDir="${webapp.path}/WEB-INF/src" /> -->
<java classname="org.apache.jasper.JspC"
classpathref="jspc.classpath"
fork="true" failonerror="true">
<arg line="-v -d ${webapp.path}/WEB-INF/src -webapp ${webapp.path}"/>
</java>
</target>
<target name="compilejsp" depends="jspc">
<mkdir dir="${webapp.path}/WEB-INF/classes"/>
<mkdir dir="${webapp.path}/WEB-INF/lib"/>
<javac destdir="${webapp.path}/WEB-INF/classes"
optimize="off"
debug="on" failonerror="false"
srcdir="${webapp.path}/WEB-INF/src"
excludes="**/*.smap">
<classpath>
<pathelement location="${webapp.path}/WEB-INF/classes"/>
<fileset dir="${webapp.path}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${tomcat.home}/lib"/>
<fileset dir="${tomcat.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${tomcat.home}/bin">
<include name="*.jar"/>
</fileset>
</classpath>
<include name="**" />
<exclude name="tags/**" />
</javac>
</target>
<!-- #######################################################################
T a r g e t : C o m p i l e
####################################################################### -->
<target name="compile">
<echo>Compiling ${ant.project.name}</echo>
<mkdir dir="${webapp.path}/WEB-INF/classes"/>
<javac includeAntRuntime="false" srcdir="src"
debug="on"
destdir="${webapp.path}/WEB-INF/classes">
<!--destdir="${webapp.path}/WEB-INF/classes">-->
<classpath>
<fileset dir="WebRoot/WEB-INF/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${tomcat.home}/lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
<copy file="src/in.xls"
tofile="${webapp.path}/WEB-INF/classes/com/xxx/ees/action/in.xls">
</copy>
<copy todir="${webapp.path}/WEB-INF/classes">
<fileset dir="src">
<include name="**"/>
<exclude name="**/*.java"/>
<exclude name="**/*.class"/>
</fileset>
</copy>
<echo>Finished compiling ${ant.project.name}</echo>
</target>
<!-- =================================
target: deploy
================================= -->
<target name="deploy" depends="war" description="--> deploys the war file locally">
<copy todir="${tomcat.home}/webapps" file="EES.war"/>
</target>
<target name="remotedeploy" depends="war">
<scp keyfile="${user.home}/.ssh/id_dsa" passphrase="" file="EES.war" remoteTodir="x@y.com.com:" verbose="true"/>
<sshexec keyfile="${user.home}/.ssh/id_dsa" host="x.y.com" username="xxx" command="/home/xxx/deployees"/>
</target>
<!-- #######################################################################
T a r g e t : C l e a n
####################################################################### -->
<target name="clean">
<echo>Cleaning ${ant.project.name}</echo>
<delete dir="${webapp.path}" >
</delete>
</target>
</project>
Any advice on how to fix?
My guess is that Ant does not "see" TOMCAT_HOME
because the system process in which Ant has been called has not that variable defined on it.
Ensure you are calling Ant from the same system user that has a TOMCAT_HOME
variable in its profile, and also that the environment variables are preserved when launching Ant.