Apache Ant 1.9.1 build.xml works fine with windows but throwing error with Linux - apache

I am trying to run my build.xml file. In windows its running fine but when i try to run the same build.xml in linux it throws below error
/ATG/TwoDegreeReplatformApp/twodegree/build/build.xml:4: The following error occurred while executing this line:
jar:file:/ATG/apache-ant-1.9.4/lib/ant.jar!/org/apache/tools/ant/antlib.xml:37: Problem: failed to create task or type componentdef
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Even i have checked the path variable in linux machine. Last week same script was working in Linux env but now started throwing error.
Below is my build file
<?xml version="1.0" encoding="UTF-8"?>
<project name="Siebel" default="all-with-ws" basedir=".">
<!-- Import global defaults and settings and common tasks -->
<import file="${basedir}/buildtools/common.xml"/>
<!-- To keep track of alters made to the schemas, place them in the sql.install.dir
and name them with alter_core_xxx.sql and alter_catalog_xxx.sql. The following
path declaration will pick them up, and they will be executed on the appropriate
schema. -->
<path id="alter.core.schema.files">
<fileset dir="${sql.alter.dir}">
<include name="alter_core*"/>
</fileset>
</path>
<path id="alter.catalog.schema.files">
<fileset dir="${sql.alter.dir}">
<include name="alter_catalog*"/>
</fileset>
</path>
<!-- ======================================= -->
<!-- Task Definitions -->
<!-- ======================================= -->
<!-- Web Serice import task - generates Java classes based on WSDL files.
This is a JAX (Java API for XML) resource.
-->
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
<classpath refid="classpath"/>
<classpath path="${dyn.classpath}" />
</taskdef>
<!-- ======================================= -->
<!-- Define the all task. We do this here because we need to call tasks
imported in both the common.xml and deploy.xml files. This may seem a
bit odd but it feels better to segregate common tasks from j2ee
deployment tasks and add this extra bit of layering than have one
massive common task file which has tons of targets, making it difficult
to read. You get my point separating the tasks in multiple imports
makes this complex environment easier to get around. -->
<target name="all"
depends="clean,build,install"
description="Cleans, builds, and installs the project.">
</target>
<!-- Does what 'all' does.
Also builds and install the web services for the "import from Siebel"
functionality.
-->
<target name="all-with-ws"
depends="clean,build,install,make-install-ws"
description="Cleans, builds, and installs the project.">
</target>
<!--
Compiles and jars the code.
Also copies the WSDL files into the classes dir to the JAR'd.
-->
<target name="build"
depends="set-dynamo-classpath,wsdl2java,compile,copy-wsdl,-jar,-copylibs,build-versioned,build-publishingagent"
description="Compiles and jars the code.">
</target>
<!-- Performs all requisite tasks for installing the module.
-->
<target name="install"
depends="-init, -createdirs, -installcore, -install-web-app,install-versioned,install-publishingagent"
description="Installs the codebase to the install directory.">
</target>
<!--
Creates and installs the Siebel web services.
-->
<target name="make-install-ws"
depends="create-ws,install-ws"
description="" >
</target>
<!--
Creates the Siebel web service.
-->
<target name="create-ws">
<antcall target="copy-siebel-ws-script" />
<exec executable="/bin/sh" dir="${dynamo.home}" failonerror="yes"
os="Linux:SunOS:Mac OS X">
<arg line="bin/generateSiebelWebService" />
</exec>
<exec executable="cmd" dir="${dynamo.home}" failonerror="yes"
osfamily="windows">
<arg line="/c bin\generateSiebelWebService.bat" />
</exec>
<move todir="${basedir}/SiebelWS/j2ee-apps" failonerror="yes">
<fileset dir="${dynamo.home}" includes="SiebelWS.ear" />
</move>
</target>
<!--
Copies the web service generation scripts to $DYNAMO_HOME/bin
so they have access to other ATG scripts.
-->
<target name="copy-siebel-ws-script">
<copy todir="${dynamo.home}/bin" failonerror="yes">
<fileset dir="${basedir}/wsGenScripts/" includes="generate*" />
</copy>
</target>
<!--
Installs the web services by copying them to the module directory.
-->
<target name="install-ws" >
<!-- Copy the web service directory -->
<copy todir="${install.dir}/SiebelWS">
<fileset dir="${basedir}/SiebelWS/"/>
</copy>
</target>
<!--
Copy WSDL files into classes dir
-->
<target name="copy-wsdl">
<copy todir="${classes.dir}/META-INF/wsdl">
<fileset dir="${src.dir}/META-INF/wsdl"/>
</copy>
</target>
<!--
Creates Java source from the WSDL files provided.
Calls another task to pass in the right classpath.
-->
<target name="wsdl2java">
<antcall target="_wsdl2java" />
</target>
<!--
Creates Java source from the WSDL files provided.
This must be called from an antcall in order to get the right classpath.
-->
<target name="_wsdl2java" depends="set-dynamo-classpath">
<echo>${gen-src.dir}</echo>
<echo>${classes.dir}</echo>
<mkdir dir="${gen-src.dir}" />
<mkdir dir="${classes.dir}" />
<property name="quiet" value="true"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/SelfServiceAccount.wsdl"
wsdllocation="http://localhost/wsdl/SelfServiceAccount.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/SelfServiceAddress.wsdl"
wsdllocation="http://localhost/wsdl/SelfServiceAddress.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/SelfServiceContact.wsdl"
wsdllocation="http://localhost/wsdl/SelfServiceContact.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/SelfServiceUser.wsdl"
wsdllocation="http://localhost/wsdl/SelfServiceUser.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/ProductConfigurator.wsdl"
wsdllocation="http://localhost/wsdl/ProductConfigurator.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/PromotionWebService.wsdl"
wsdllocation="http://localhost/wsdl/PromotionWebService.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/CalculatePriceWS.wsdl"
wsdllocation="http://localhost/wsdl/CalculatePriceWS.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/SelfServiceAccountBillingProfile.wsdl"
wsdllocation="http://localhost/wsdl/SelfServiceAccountBillingProfile.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/QuotingWebService.wsdl"
wsdllocation="http://localhost/wsdl/QuotingWebService.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/OrderDetailWebService.wsdl"
wsdllocation="http://localhost/wsdl/OrderDetailWebService.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/OrderWebService.wsdl"
wsdllocation="http://localhost/wsdl/OrderWebService.wsdl"/>
<wsimport keep="true"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/AssetManagement.wsdl"
wsdllocation="http://localhost/wsdl/AssetManagement.wsdl"/>
<wsimport keep="true"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/AssetManagementComplex.wsdl"
wsdllocation="http://localhost/wsdl/AssetManagementComplex.wsdl"/>
<wsimport keep="true" quiet="${quiet}"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/QuoteEligibilityCompatibility.wsdl"
wsdllocation="http://localhost/wsdl/QuoteEligibilityCompatibility.wsdl"/>
<wsimport keep="true"
sourcedestdir="${gen-src.dir}" destdir="${classes.dir}"
wsdl="${wsdl.dir}/CatalogWebService.wsdl"
wsdllocation="http://localhost/wsdl/CatalogWebService.wsdl"/>
</target>
<!-- Installs the JSP files to the target WAR directory.
-->
<target name="install-jsps" description="Copy JSPs">
<filter token="*.js*" value="${install.dir}/j2ee-apps/Siebel/siebel.war" />
<copy todir="${install.dir}/j2ee-apps/Siebel/siebel.war" preservelastmodified="true" filtering="true" encoding="ISO-8859-1">
<fileset dir="${basedir}/j2ee/siebel.war" />
</copy>
</target>
<target name="-install-web-app" description="Installs all module's web applications into installation directory.">
<!-- Copy config files only and apply filtering to them. -->
<copy todir="${install.j2ee.dir}/${module.name}">
<fileset dir="${j2ee.dir}"/>
</copy>
<!-- Copy all necessary taglibs into each target WEB-INF directory. -->
<foreach param="target.webinf.dir" target="-copy-taglibs">
<path>
<dirset dir="${install.j2ee.dir}/${module.name}">
<include name="**/WEB-INF"/>
</dirset>
</path>
</foreach>
</target>
<target name="build-versioned"
depends="set-dynamo-classpath"
description="Builds the Java code in the Versioned sub-module">
<mkdir dir="${classes.versioned.dir}" />
<echo message="DYNAMO CLASSPATH = ${dyn.classpath}"/>
<property name="prop.classpath" refid="classpath" />
<echo message="CLASSPATH = ${prop.classpath}"/>
<javac srcdir="${src.versioned.dir}"
destdir="${classes.versioned.dir}"
debug="true"
deprecation="false"
optimize="false"
source="1.5"
target="1.5"
includeantruntime="false"
verbose="${javac.verbose.bool}">
<classpath refid="classpath"/>
<classpath path="${dyn.classpath}"/>
<classpath path="${classes.dir}"/>
<include name="**/*.java" />
</javac>
<!-- create classes.jar -->
<mkdir dir="${build.versioned.dir}/lib" />
<jar jarfile="${build.versioned.dir}/lib/classes.jar"
basedir="${classes.versioned.dir}/"
includes="**"/>
<!-- copy config files -->
<mkdir dir="${build.tempconfig.versioned.dir}" />
<copy todir="${build.tempconfig.versioned.dir}" filtering="true">
<fileset dir="${config.versioned.dir}" />
</copy>
</target>
<target name="install-versioned" description="Installs the Versioned sub-module">
<!-- copy classes.jar -->
<mkdir dir="${build.versioned.dir}/lib"/>
<copy file="${build.versioned.dir}/lib/classes.jar" todir="${install.versioned.dir}/lib"/>
<!-- copy config files -->
<mkdir dir="${install.versioned.dir}/config" />
<copy todir="${install.versioned.dir}/config">
<fileset dir="${build.tempconfig.versioned.dir}" />
</copy>
<!-- Copy manifest file -->
<mkdir dir="${install.versioned.dir}/META-INF" />
<copy file="${versioned.dir}/META-INF/MANIFEST.MF" todir="${install.versioned.dir}/META-INF"/>
</target>
<target name="build-publishingagent"
depends="set-dynamo-classpath"
description="Builds the publishingagent sub-module">
<mkdir dir="${classes.publishingagent.dir}" />
<echo message="DYNAMO CLASSPATH = ${dyn.classpath}"/>
<property name="prop.classpath" refid="classpath" />
<echo message="CLASSPATH = ${prop.classpath}"/>
<javac srcdir="${src.publishingagent.dir}"
destdir="${classes.publishingagent.dir}"
debug="true"
deprecation="false"
optimize="false"
source="1.5"
target="1.5"
includeantruntime="false"
verbose="${javac.verbose.bool}">
<classpath refid="classpath"/>
<classpath path="${dyn.classpath}"/>
<classpath path="${classes.dir}"/>
<include name="**/*.java" />
</javac>
<!-- create classes.jar -->
<mkdir dir="${build.publishingagent.dir}/lib" />
<jar jarfile="${build.publishingagent.dir}/lib/classes.jar"
basedir="${classes.publishingagent.dir}/"
includes="**"/>
<!-- copy config files -->
<mkdir dir="${build.tempconfig.publishingagent.dir}" />
<copy todir="${build.tempconfig.publishingagent.dir}" filtering="true">
<fileset dir="${config.publishingagent.dir}" />
</copy>
</target>
<target name="install-publishingagent" description="Installs the PublishingAgent sub-module">
<!-- copy classes.jar -->
<mkdir dir="${build.publishingagent.dir}/lib"/>
<copy file="${build.publishingagent.dir}/lib/classes.jar" todir="${install.publishingagent.dir}/lib"/>
<!-- copy config files -->
<mkdir dir="${install.publishingagent.dir}/config" />
<copy todir="${install.publishingagent.dir}/config">
<fileset dir="${build.tempconfig.publishingagent.dir}" />
</copy>
<!-- Copy manifest file -->
<mkdir dir="${install.publishingagent.dir}/META-INF" />
<copy file="${publishingagent.dir}/META-INF/MANIFEST.MF" todir="${install.publishingagent.dir}/META-INF"/>
</target>
</project>

The ANT error indicates that your build is missing jars required by a 3rd party ANT task.
The following documentation describes the wsimport task:
https://jax-ws.java.net/2.2.3/docs/wsimportant.html
States the external task is declared as follows:
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
<classpath
path="jaxws.classpath"/>
</taskdef>
With the following description of the classpath:
where jaxws.classpath is a reference to a path-like structure, defined
elsewhere in the build environment, and contains the list of classes
required by the JAX-WS tools.
So looks like you need to doublecheck the path declaration in your build and ensure that the JAX-WS jars are installed.

There's missing information in your build.xml file:
<import file="${basedir}/buildtools/common.xml"/>
Much of your build.xml is embedded in that common.xml file. You listed your entire build.xml, but not that file.
For example, your taskdef depends upon classpath being set, and ${dyn.classpath} being defined. They're not defined in your build.xml file. You also use foreach which I assume comes from the Ant Contrib jar, but the <taskdef> from your build.xml doesn't contain that either.
I suspect that your Windows Ant may contain third party jars in $ANT_HOME/lib, or that other setup issues may exist that you depend upon on your Windows machine, but aren't in that Linux machine.

Related

ant junit selenium wont run in jenkins

I have junit tests that use selenium to test web server.
When i run the tests using ant from command line, everything is working fine, browser gets opened and tests are going as planed.Browser gets open and i can see tests running.
Recently ive tried to add automatic tests as part of Ci cycle running on jenkins.
I run it as ant build command.
I can see that ant is executing properly (test classes are built i can see output from tests to console) but browser window never gets opened and test fails because of it. here is my ant file
<?xml version="1.0"?>
<project name="JUNIT" default="main" basedir="../../project" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<!-- Sets variables which can later be used. -->
<!-- The value of a property is accessed via ${} -->
<property name="api.dir" location="src/java" />
<property name="build.api.dir" location="target/classes" />
<property name="test.dir" location="src/test/java" />
<property name="build.test.dir" location="target" />
<!-- Variables used for JUnit testin -->
<property name="test.report.dir" location="testreport" />
<!-- Define the classpath which includes the junit.jar and the classes after compiling-->
<path id="api.class.path">
<pathelement location="${build.api.dir}" />
</path>
<artifact:dependencies cacheDependencyRefs="true" pathId="pomdeps.path">
<pom file="pom.xml"/>
</artifact:dependencies>
<target name="clean">
<delete dir="${test.report.dir}" />
<delete dir="${build.api.dir}" />
<delete dir="${build.test.dir}" />
</target> <!-- Creates the build, docs and dist directory-->
<target name="makedir">
<echo message="Make dir"/>
<mkdir dir="${build.test.dir}" />
<mkdir dir="${build.api.dir}" />
<mkdir dir="${test.report.dir}" />
</target> <!-- Compiles the java code (including the usage of library for JUnit -->
<target name="compile" depends="clean, makedir">
<echo message="Compile"/>
<javac srcdir="${api.dir}" destdir="${build.api.dir}" includeantruntime="false">
<!--classpath refid="junit.class.path" />
<classpath refid="libs.class.path" /-->
<classpath refid="pomdeps.path" />
</javac>
<javac srcdir="${test.dir}" destdir="${build.test.dir}" includeantruntime="false">
<!--classpath refid="junit.class.path" /-->
<classpath refid="api.class.path" />
<classpath refid="pomdeps.path" />
</javac>
</target>
<!-- Run the JUnit Tests --> <!-- Output is XML, could also be plain-->
<echo message="Classes folder ${build.test.dir}"/>
<target name="junit" depends="compile" >
<echo message="junit"/>
<junit printsummary="on" fork="false" haltonfailure="no" showoutput="true">
<classpath refid="pomdeps.path" />
<classpath>
<pathelement location="${build.test.dir}"/>
<pathelement location="${build.api.dir}"/>
</classpath>
<formatter usefile="false" type="plain"/>
<batchtest fork="no" todir="${test.report.dir}">
<fileset dir="${test.dir}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="main" depends="compile, junit">
<description>Main target</description>
</target>
</project>
Jenkins is 1.591 i installed it with default parameters as windows installation downloaded from their site.
Can it be something wrong with jenkins? Do i miss something?
As i mentioned earlier the problem was lack of UI permissions for Jenkins server.
1.configure Jenkins to run as service and make it login with real user name
2.Make sure that windows host that runs Jenkins logs on automaticaly after restart.

Ant Build: Not finding local.properties or build_web_extras.properties

Just installed Apache Ant and Maven Ant tasks. I have a build.xml in my project that I'm trying to run as an Ant Build, but when I try to run it, it returns the following:
Unknown argument: -build
Buildfile: C:\Users\arempel\workspace\cis\cisbackend\build.xml
[mvn:dependencies] [INFO] snapshot choicehotels.util.io:choice-io:0.0.3-SNAPSHOT: checking for updates from nexus
[mvn:dependencies] [WARNING] repository metadata for: 'snapshot choicehotels.util.io:choice-io:0.0.3-SNAPSHOT' could not be retrieved from repository: nexus due to an error: Error transferring file: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[mvn:dependencies] [INFO] Repository 'nexus' will be blacklisted
local-properties-found:
local-properties-not-found:
[echo] local.properties file not found in ../.., ../, or C:\Users\arempel/eclipse_properties
build-web-extras-found:
build-web-extras-not-found:
[echo] build_web_extras.properties file not found in ../.., ../, or C:\Users\arempel/eclipse_properties
report-local-properties:
-verify_local_properties:
BUILD FAILED
C:\Users\arempel\workspace\cis\cisbackend\build.xml:47: local.properties or build_wewb_extras.properties file not found
Total time: 1 second
I'm not sure where to start looking to fix this. It might be an environment variable but I have Ant added under Users\myusername\apache-ant-1.9.1, so I'm not sure what I need to do.
EDIT: Added the build.xml
<project name="cisbackend" default="local" basedir="."
xmlns:mvn="antlib:org.apache.maven.artifact.ant">
<!-- ===================== Property Definitions =========================== -->
<!-- locate the local.properties and build_web_extras.properties files within the workspace -->
<import file="../locate-local-properties.xml" />
<property file="${local.properties.dir}/build_web_extras.properties"/>
<property environment="env"/>
<property name="app.name" value="cisbackend"/>
<property name="compile.debug" value="true"/>
<property name="compile.deprecation" value="false"/>
<property name="compile.optimize" value="false"/>
<property name="compile.home" value="target"/>
<property name="package.home" value="target/package"/>
<property name="resources" value="src/main/resources" />
<property name="xsl.home" value="${resources}/xsl"/>
<property name="images.home" value="${resources}/images"/>
<property name="dist.home" value="target/dist"/>
<!-- -->
<macrodef name="runmvn">
<element name="args" optional="yes"/>
<sequential>
<mvn:mvn mavenHome="${env.MAVEN_HOME}" fork="true" dir="${basedir}" failonerror="true">
<args /> <!-- additional arg elements specified by the caller-->
</mvn:mvn>
</sequential>
</macrodef>
<!-- Set up the compiler CLASSPATH -->
<mvn:dependencies filesetId="maven.dependencies" useScope="compile">
<pom file="pom.xml"/>
</mvn:dependencies>
<path id="compile.classpath">
<fileset refid="maven.dependencies" />
</path>
<target name="-verify_local_properties" depends="report-local-properties">
<fail message="local.properties or build_wewb_extras.properties file not found" unless="configuration-is-valid" />
</target>
<!-- ==================== Clean Target ==================================== -->
<target name="clean">
<runmvn>
<args>
<arg value="clean" />
</args>
</runmvn>
</target>
<!-- ==================== Compile Target ================================== -->
<target name="-compile">
<runmvn>
<args>
<arg value="compile" />
</args>
</runmvn>
</target>
<!-- ==================== Build Target ==================================== -->
<target name="-build" depends="-compile">
<mkdir dir="${package.home}/lib"/>
<!-- Copy jar files into the package directory -->
<jar destfile="${package.home}/lib/cisbackend.jar"
basedir="${compile.home}/classes">
<exclude name="*"/>
</jar>
<copy todir="${package.home}/lib" flatten="true">
<fileset refid="maven.dependencies" />
</copy>
<!-- Copy property files and stylesheets -->
<copy todir="${package.home}/classes">
<fileset dir="target/classes" includes="*"/>
</copy>
<!-- Copy scripts -->
<copy todir="${package.home}">
<fileset dir="src/scripts"/>
</copy>
<copy todir="${package.home}/control">
<fileset dir="src/control"/>
</copy>
<copy todir="${package.home}/xsl">
<fileset dir="${xsl.home}"/>
</copy>
<copy todir="${package.home}/images">
<fileset dir="${images.home}"/>
</copy>
</target>
<!-- ==================== Replace Target ================================= -->
<target name="-replace">
<echo message="Replacing tokens found in property file ${replace.file}"/>
<!-- Copy environment specific configuration files -->
<copy todir="${package.home}/${replace.dir}">
<fileset dir="src/config"/>
</copy>
<replace dir="${package.home}/${replace.dir}"
replaceFilterFile="${replace.file}"
summary="yes"/>
</target>
<!-- ==================== Dist Target ===================================== -->
<target name="-dist">
<mkdir dir="${dist.home}"/>
<!-- For some reason ANT doesn't figure out the TAR file needs to be
changed so delete it first -->
<delete file="${dist.home}/cisbackend.tar"/>
<!-- Create application TAR file -->
<tar tarfile="${dist.home}/cisbackend.tar">
<tarfileset dir="${package.home}" mode="755">
<include name="*.sh"/>
</tarfileset>
<tarfileset dir="${package.home}">
<include name="**"/>
<exclude name="*.sh"/>
</tarfileset>
</tar>
<mvn:install file="${package.home}/lib/cisbackend.jar">
<pom file="pom.xml"/>
</mvn:install>
</target>
<!-- ==================== Deploy Target =================================== -->
<target name="-deploy" depends="-dist">
<!-- Deploy the TAR file -->
<exec executable="/cis/cisdev/bin/copyanddeploy">
<arg value="${version}"/>
<arg file="${dist.home}/cisbackend.tar"/>
</exec>
</target>
<target name="hudson.copytodeploy">
<property file="target/classes/version.properties" prefix="project"/>
<copy todir="${build.deploy.dir}" verbose="true">
<fileset dir="${dist.home}" includes="*.war,*.tar"/>
<globmapper from="*" to="*.${project.version.major}-${project.version.minor}-${project.version.build}" />
</copy>
</target>
<!-- ==================== Local Targets =================================== -->
<target name="-local_replace" depends="-build">
<!-- define default for dev.replace.file in case developer
does not define in build_web_extras.properties -->
<property name="cisbackend.replace.file" value="dev1.properties" />
<!-- replace tokens specified in the developer's local.properties file -->
<antcall target="-replace">
<param name="replace.file" value="${local.properties.dir}/local.properties"/>
<param name="replace.dir" value="config"/>
</antcall>
<!-- replace any additional tokens using the file
specified by the cisbackend.replace.file property in the developer's
build_web_extras.properties file -->
<antcall target="-replace">
<param name="replace.file" value="${cisbackend.replace.file}"/>
<param name="replace.dir" value="config"/>
</antcall>
</target>
<target name="local_clean" depends="clean"/>
<!-- This target should be used for creating a build on your local machine. -->
<target name="local" description="Build the project for your machine"
depends="-verify_local_properties, local_clean, -local_replace, -dist" />
<!-- ==================== Distribution Targets ============================ -->
<target name="-dist-replace" depends="-build">
<antcall target="-replace">
<param name="replace.file" value="dev1.properties"/>
<param name="replace.dir" value="config-dev1"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="dev2.properties"/>
<param name="replace.dir" value="config-dev2"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="dev3.properties"/>
<param name="replace.dir" value="config-dev3"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="qa2.properties"/>
<param name="replace.dir" value="config-qa2"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="qa1.properties"/>
<param name="replace.dir" value="config-qa1"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="prod1.properties"/>
<param name="replace.dir" value="config-prod1"/>
</antcall>
</target>
<target name="-dist_clean" depends="clean"/>
<!-- This target should be used for creating a release build. -->
<target name="build.release" description="Build a release"
depends="-dist_clean, -dist-replace, -dist"/>
</project>
UPDATE
1) Initially at the beginning of the build output that you posted there was Unknown argument: -build. I suppose that changing the build target name fixed it. Otherwise you need to state clearly which commands you're running and in which context.
2) The build seems to depend on the environment and the local.properties file is missing. You can either make sure it's there or ensure that you're pointing at the right location.
This could also be related to some properties not being imported properly, but only you would know that for sure..
What happens when you rename the -build target to just build?
See the concept of hidden/private targets:
http://ant.1045680.n5.nabble.com/private-targets-td1350568.html
http://www.jrenard.info/blog/creating-private-targets-with-ant.html
http://extendit.us/private-ant-targets/

How to take back up of existing projects of remote server using ant

I am deploying my application using ant build script mention below. my application gets deployed on specified server mentioned in my ant script. but i want to take back of existing deployed project on remote server before i deployed new project. Here is my ant script.
<?xml version="1.0"?>
<project name="xyz" basedir="." default="deploy">
<!-- Read values from buildscript properties file -->
<property file="buildscript.properties" />
<!-- set global variable for this build -->
<property name="build" value="${basedir}/build"/>
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="war.dir" value="${build.dir}/war"/>
<!-- Configure the context path for this application -->
<property name="path" value="/xyz"/>
<!-- set class path -->
<path id="compile.classpath">
<fileset dir="WebContent/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${tomcatDir}">
<include name="*.jar"/>
</fileset>
</path>
<!-- Configure the custom Ant tasks for the Tomcat Server Manager -->
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="compile.classpath" />
</taskdef>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask">
<classpath refid="compile.classpath" />
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="compile.classpath" />
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="compile.classpath" />
</taskdef>
<!-- delete build directory -->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!-- create classes, war directory in build -->
<target name="create" depends="clean">
<mkdir dir="${classes.dir}"/>
<mkdir dir="${war.dir}"/>
</target>
<!-- compile source code and put classes in classes dir -->
<target name="compile" depends="create">
<copy todir="${classes.dir}" overwrite="true">
<fileset dir="src" excludes="*.java"/>
</copy>
<!-- for replacing cfg file to deploy on stagging-->
<copy todir="${classes.dir}" overwrite="true">
<fileset dir="${configurationFileDir}">
<include name="*.xml"/>
</fileset>
</copy>
<javac destdir="${classes.dir}" srcdir="${src.dir}" debug="true">
<classpath refid="compile.classpath"/>
</javac>
</target>
<!-- create war file -->
<target name="war" depends="compile">
<war destfile="${war.dir}/xyz.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent"/>
<classes dir="build/classes"/>
</war>
</target>
<!-- Deploy war file -->
<target name="deploy" description="Install web application"
depends="war">
<deploy url="${url}" username="${username}" password="${password}"
path="${path}" war="file:${war.dir}/xyz.war"/>
</target>
<!-- Start apllication -->
<target name="start" description="start application in tomcat">
<start url="${url}" username="${username}" password="${password}" path="${path}"/>
</target>
<!-- Undeploy war file -->
<target name="undeploy" description="Remove web application" >
<undeploy url="${url}" username="${username}" password="${password}"
path="${path}"/>
</target>
<!-- Stop apllication -->
<target name="stop" description="stop application in tomcat">
<stop url="${url}" username="${username}" password="${password}" path="${path}"/>
</target>
</project>
The manager documentation describes a special tag attribute that can be used to redeploy your application:
URL parameters include:
update: When set to true, any existing update will be undeployed first....
tag: Specifying a tag name, this allows associating the deployed webapp
with a tag or label. If the web application is undeployed, it can be
later redeployed when needed using only the tag.
Unfortunately, the ANT task documentation does not describe any support for this attribute...
Interestingly, the Maven plugin does support this, but switching build tool would be a rather extreme solution to this problem :-)

TestNG Selenium Test fails in Ant through command prompt

I am using Selenium testNG in eclipse to run my test cases.The testNg.xml file executes the test correctly.
But when I try to run in command prompt through ant the build is success but the test fails.
one peculiar thing happening is : when the driver i use to test is HtmlUnitdriver build is successful and also the test passes . But it fails when i use other browsers like firefox, chrome, explorer in my test case.
the build.xml i use is:
<project name="Automation" default="clean" basedir=".">
<property name="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="src.dir" value="${basedir}/src"/>
<target name="setClassPath">
<path id="classpath_jars">
<pathelement path="${basedir}/" />
<fileset dir="${lib.dir}" includes="*.jar" />
</path>
<pathconvert pathsep=":" property="test.classpath" refid="classpath_jars" />
</target>
<target name="loadTestNG" depends="setClassPath">
<taskdef resource="testngtasks" classpath="${test.classpath}"/>
</target>
<target name="init">
<mkdir dir="${build.dir}"/>
<tstamp>
<format property="timestamp" pattern="dd-MM-yyyy_(HH-mm-ss)"/>
</tstamp>
<property name="build.log.dir" location="${basedir}/buildlogs"/>
<mkdir dir="${build.log.dir}"/>
<property name="build.log.filename" value="build_${timestamp}.log"/>
<record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
<echo message="build logged to ${build.log.filename}"/>
</target>
<target name="clean">
<echo message="deleting existing build directory"/>
<delete dir="${build.dir}"/>
</target>
<target name="compile" depends="clean,init,setClassPath,loadTestNG">
<echo message="classpath:${test.classpath}"/>
<echo message="compiling.........."/>
<javac destdir="${build.dir}" srcdir="${src.dir}" classpath="${test.classpath}"/>
</target>
<target name="runTests" depends="compile">
<testng classpath="${test.classpath}:${build.dir}">
<xmlfileset dir="${basedir}" includes="testNg.xml"/>
</testng>
</target>
</project>
I appreciate any help.

java.lang.NoClassDefFoundError when trying to run JUnit tests from ANT

I'm having problems with a java.lang.NoClassDefFoundError when trying to run my JUnit tests from ANT using the runtestsreport task in thefollowing build.xml; I know the other tasks work, it's just the actual running of the tests that's the problem.
I've tried lots of adjustments based on questions posted on here but I can't fix it; what I really need is a dev to pair with but they've all gone home for the day.
Can anyone help?
The build.xml file is
<property name="build" location="C:\<path on my machine>\workspace\ESS\build"/>
<property name="testsbuild" location="C:\<path on my machine>\workspace\ESS\build\esstestapp\tests"/>
<property name="frameworkbuild" location="C:\<path on my machine>\workspace\ESS\build\esstestapp\framework"/>
<property name="rawtestreports" location="C:\<path on my machine>\workspace\ESS\reports\raw"/>
<property name="htmltestreports" location="C:\<path on my machine>\workspace\ESS\reports\html"/>
<property name="reports" location="C:\<path on my machine>\workspace\ESS\reports"/>
<property name="src" location="C:\<path on my machine>\workspace\ESS\src"/>
<property name="testsrc" location="C:\<path on my machine>\workspace\ESS\src\esstestapp\tests"/>
<property name="seleniumtools" location="C:\<path on my machine>\workspace\ESS\tools\junit-4.8.2"/>
<property name="junittools" location="C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2"/>
<target name="init">
<tstamp/>
<mkdir dir="${build}"/>
<mkdir dir="${rawtestreports}"/>
<mkdir dir="${htmltestreports}"/>
</target>
<path id="tools.classpath">
<fileset dir="${seleniumtools}" includes="**/*.jar"/>
<fileset dir="${junittools}" includes="**/*.jar"/>
</path>
<target name="compile" depends="init" description="compile the source" >
<javac srcdir="${src}" destdir="${build}" classpathref="tools.classpath" includeantruntime="false"/>
</target>
<target name="frameworkjar" depends="compile">
<jar destfile="${frameworkbuild}/jar/framework.jar" basedir="${frameworkbuild}" />
</target>
<target name="testsjar" depends="compile">
<jar destfile="${testsbuild}/jar/tests.jar" basedir="${testsbuild}" />
</target>
<path id="test.classpath">
<fileset dir="${seleniumtools}" includes="**/*.jar"/>
<fileset dir="${junittools}" includes="**/*.jar"/>
<fileset dir="${testsbuild}/jar" includes="**/*.jar"/>
<fileset dir="${frameworkbuild}/jar" includes="**/*.jar"/>
</path>
<target name="runtests" depends="compile, frameworkjar, testsjar" description="runs the tests" >
<junit printsummary="yes" haltonfailure="no" showoutput="yes" fork="no">
<classpath refid="test.classpath" />
<batchtest fork="yes" todir="${rawtestreports}">
<formatter type="xml"/>
<fileset dir="${testsrc}">
<include name="**/*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="runtestsreport" depends="runtests">
<junitreport todir="${reports}">
<fileset dir="${rawtestreports}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${htmltestreports}" />
</junitreport>
</target>
<target name="clean" description="Clean up">
<delete dir="${build}"/>
<delete dir="${reports}"/>
</target>
I get this error (and this type of error for each test class)
Credentials (wrong name: esstestapp/tests/Credentials)
java.lang.NoClassDefFoundError: Credentials (wrong name: esstestapp/tests/Credentials)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)...
I've ran ant in -verbose mode to check the classpath out but I can't see the problem (even though I know that it's staring me in the face)
[junit] Implicitly adding C:\Program Files\apache-ant-1.8.2\lib\ant-launcher
.jar;C:\Program Files\apache-ant-1.8.2\lib\ant.jar;C:\Program Files\apache-ant-1
.8.2\lib\ant-junit.jar;C:\Program Files\apache-ant-1.8.2\lib\ant-junit4.jar to C
LASSPATH
[junit] Executing 'C:\Program Files\Java\jdk1.6.0_25\jre\bin\java.exe' with
arguments:
[junit] '-classpath'
[junit] Executing 'C:\Program Files\Java\jdk1.6.0_25\jre\bin\java.exe' with
arguments:
[junit] '-classpath'
[junit] 'C:\<path on my machine>\workspace\ESS\tools\junit-4.8.2\junit.jar;C:\User
s\waltersj\workspace\ESS\tools\junit-4.8.2\junitsrc.jar;C:\<path on my machine>\worksp
ace\ESS\tools\selenium-2.0rc2\apache-mime4j-0.6.jar;C:\<path on my machine>\workspace\
ESS\tools\selenium-2.0rc2\bsh-1.3.0.jar;C:\<path on my machine>\workspace\ESS\tools\se
lenium-2.0rc2\cglib-nodep-2.1_3.jar;C:\<path on my machine>\workspace\ESS\tools\seleni
um-2.0rc2\commons-codec-1.4.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2
.0rc2\commons-collections-3.2.1.jar;C:\<path on my machine>\workspace\ESS\tools\seleni
um-2.0rc2\commons-io-2.0.1.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.
0rc2\commons-lang-2.4.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\
commons-logging-1.1.1.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\
cssparser-0.9.5.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\guava-
r09.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\hamcrest-all-1.1.j
ar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\htmlunit-2.8.jar;C:\Use
rs\waltersj\workspace\ESS\tools\selenium-2.0rc2\htmlunit-core-js-2.8.jar;C:\User
s\waltersj\workspace\ESS\tools\selenium-2.0rc2\httpclient-4.0.2.jar;C:\Users\wal
tersj\workspace\ESS\tools\selenium-2.0rc2\httpcore-4.0.1.jar;C:\<path on my machine>\w
orkspace\ESS\tools\selenium-2.0rc2\httpmime-4.0.1.jar;C:\<path on my machine>\workspac
e\ESS\tools\selenium-2.0rc2\jcommander-1.13.jar;C:\<path on my machine>\workspace\ESS\
tools\selenium-2.0rc2\jna.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.0
rc2\json-20080701.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\juni
t-dep-4.8.1.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\nekohtml-1
.9.14.jar;C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\sac-1.3.jar;C:\U
sers\waltersj\workspace\ESS\tools\selenium-2.0rc2\selenium-java-2.0rc2-srcs.jar;
C:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\selenium-java-2.0rc2.jar;C
:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\serializer-2.7.1.jar;C:\Use
rs\waltersj\workspace\ESS\tools\selenium-2.0rc2\testng-6.0.1-nobsh-noguice.jar;C
:\<path on my machine>\workspace\ESS\tools\selenium-2.0rc2\xalan-2.7.1.jar;C:\Users\wa
ltersj\workspace\ESS\tools\selenium-2.0rc2\xercesImpl-2.9.1.jar;C:\Users\walters
j\workspace\ESS\tools\selenium-2.0rc2\xml-apis-1.3.04.jar;C:\<path on my machine>\work
space\ESS\build\esstestapp\tests\jar\tests.jar;C:\<path on my machine>\workspace\ESS\b
uild\esstestapp\framework\jar\framework.jar;C:\<path on my machine>\workspace\ESS;C:\P
rogram Files\Java\jre6\lib\ext\QTJava.zip;C:\Program Files\apache-ant-1.8.2\lib\
ant-launcher.jar;C:\Program Files\apache-ant-1.8.2\lib\ant.jar;C:\Program Files\
apache-ant-1.8.2\lib\ant-junit.jar;C:\Program Files\apache-ant-1.8.2\lib\ant-jun
it4.jar'
Any eyes over this to help me get the tests running would be greatly appreciated.
Thanks
James
Update
I observe that if I edit tests.classpath to remove the following 2 lines then the error I see switches to a ClassNotFound which makes sense as it has no references to the .jar files that contain the classes.
<fileset dir="${testsbuild}/jar" includes="**/*.jar"/>
<fileset dir="${frameworkbuild}/jar" includes="**/*.jar"/>
With the above 2 lines present in the tests.classpath is happily finds them but with the wrong name and it's that error I don't know how to fix.
Problem caused by the following jar command:
<jar destfile="${testsbuild}/jar/tests.jar" basedir="${testsbuild}" />
The testsbuild property should be set to
<property name="testsbuild" location="C:\<path on my machine>\workspace\ESS\build"/>
Explanation
The file Credentials.class was compiled as the class esstestapp.tests.Credentials. It needs to be found on the classpath as the file:
esstestapp/tests/Credentials.class