Classpath error when calling ant from cruisecontrol

ssherlock used Ask the Experts™
Using CruiseControl to build a web service I have the following in the build script to get the version of the build so that a directory can be built (named that version number) and the EAR file stored there.  This is so we can quickly get a archived builds (rather than extract from VSS by label and rebuild).
The question is how to get at a class within the WAR (that is already in the EAR)?  I am getting classpath errors with the following:
<!-- The following works fine and creates the GetVersion.class file, which is stored in the war file -->
<mkdir dir="src/appl/version"/>
<exec dir="src/appl/version" executable="cmd" output="src/appl/version/" >
  <arg line="/c echo package appl.version; import appl.common.util.Utils; public class GetVersion { public static void main(String[] args) { System.out.println(Utils.VERSION); } }"/>
<ant antfile="build.xml" target="build_all"/>

<!-- The following fails due to a classpath error -->
<java classname="appl.version.GetVersion" outputproperty="dcp.version"/>

<!-- Any reference to dcp.version just adds ${dcp.version} rather than the hoped for version number -->
<vsslabel serverpath="S:/AppData/CH/AppDev/LWS/SourceSafe" vsspath="${vss.project}" label="Client ${dcp.version}" />
<mkdir dir="S:/AppData/CH/AppDev/Web service builds/DebitCardPaymentServerV002/${dcp.version}" />
<copy file="DebitCardPaymentServer.earV002.Prod" tofile="S:/AppData/CH/AppDev/Web service builds/DebitCardPaymentServerV002/${dcp.version}/DebitCardPaymentServer.earV002.Prod"/>
<copy file="DebitCardPaymentServer.earV002.UAT" tofile="S:/AppData/CH/AppDev/Web service builds/DebitCardPaymentServerV002/${dcp.version}/DebitCardPaymentServer.earV002.UAT"/>
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mick BarryJava Developer
Top Expert 2010

>  which is stored in the war file

it can't access the class from the war file.
you'll need to have a copy in some directory and specify that directory using the classpath parameter of the java task


Tried that.  When being compiled the GetVersion.class file is created in the following directory: C:\lws_cruise\checkout\dcp_V002\jardir\WEB-INF\classes so I added that to the classpath (or thought I did) remembering to change \ for / but get the following errors in the cruisecontrol log:
<task location="C:\lws_cruise\build-dcpV002.xml:19:" name="java" time="0 seconds">
 <message priority="error">
 <![CDATA[ Could not find GetVersion. Make sure you have it in your classpath
I've tried various connotations with no luck.

As a matter of interest where/how should I set the classpath?  Either in the build file i.e.
<java classname="GetVersion" outputproperty="dcp_version">
      <fileset dir="C:/lws_cruise/checkout/dcp_V002/jardir/WEB-INF/classes">
        <include name="GetVersion.class"/>
or somewhere else?


Figured it out.

I changed the cruisecontrol build script to the following:
<java classname="GetVersion" outputproperty="dcp_version">
         <classpath path="C:/lws_cruise/checkout/dcp_V002/jardir/WEB-INF/classes" />
rather than usuing the <fileset> tag above
Java Developer
Top Expert 2010
you can specify the classpath as an attribute

<java classname="GetVersion" outputproperty="dcp_version" classpath="C:/lws_cruise/checkout/dcp_V002/jardir/WEB-INF/classes" />

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial