ANT Permission problems

423 views
Skip to first unread message

Clarkee21

unread,
Apr 4, 2008, 4:56:42 AM4/4/08
to CFEclipse Users
Hi guys,

I know this isn't specifically CFE related but I thought you might be
able to help me. I've the tedious task of having to deploy 120+ files
onto two test servers (later onto two production servers). I thought
this was a good time to look at trying ANT to drop the files in. So
this is my first attempt :-)

I've written the script below to try and test that everything is
working correctly but when I run it I get the following error in my
console:

----

Buildfile: K:\cfusion.war\build.xml
[copy] Copying 1 file to P:\cfusion.war

BUILD FAILED
K:\cfusion.war\build.xml:14: Failed to copy K:\cfusion.war\about
\default.cfm to P:\cfusion.war\about\default.cfm due to
java.io.FileNotFoundException P:\cfusion.war\about\default.cfm (Access
is denied) and I couldn't delete the corrupt P:\cfusion.war\about
\default.cfm

Total time: 1 second

------

The ANT script looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project name="deployBugID512Fix" default="" basedir=".">
<description>
Deploy the update default.cfm files to the cluster
</description>
<!-- Dev server location -->
<property name="dev" value="K:/cfusion.war/" />
<!-- Test server location(s) -->
<property name="test1" value="O:/cfusion.war/" />
<property name="test2" value="P:/cfusion.war/" />


<!-- copy file(s) -->
<copy todir="${test2}">
<filelist dir="${dev}">
<file name="about/default.cfm" />
</filelist>
</copy>
</project>

----

If I try and copy files manually from one network drive to another it
works fine so it's probably my lack of understanding on how this works
that's stopping me.

Could someone possbily give me some advice?

Thanks a lot,
James

Clarkee21

unread,
Apr 4, 2008, 4:59:52 AM4/4/08
to CFEclipse Users
P.S. I'm running Windows XP and accessing two VM's both running 2003

Clarkee21

unread,
Apr 4, 2008, 5:33:50 AM4/4/08
to CFEclipse Users
Managed to fix it. It didn't like the user of the letter drives. It
had to be absolute paths to the servers instead.

My question after that was goign to be how do you get ANT to deploy on
more than one server. I was reading some stuff on dependencies and
changing of tokens but I can't seem to find working examples.

Marc Esher

unread,
Apr 4, 2008, 6:55:36 AM4/4/08
to cfeclip...@googlegroups.com
Clarkee, when you say "how do you deploy to more than one server", are
you talking about how to use ant to straight-up copy files to multiple
servers?

like, in pseudocode, do you want to do this:


set servers = "\\my-server1\,\\my-server2,\\my-server3"
for each server
copy all files from this dir into {server}\thatdir

??

Marc

Marc Esher

unread,
Apr 4, 2008, 6:58:44 AM4/4/08
to cfeclip...@googlegroups.com
or do you want even simpler than that, i.e. no looping. Like, you know
you only have two servers, and you just want to do this:

(in pseudocode):

DeployToServer("\\my-server")
DeployToServer("\\my-server2")

Clarkee21

unread,
Apr 4, 2008, 7:14:34 AM4/4/08
to CFEclipse Users
Hi Marc,

At this stage I want to just deploy it to two servers - Test1 and
Test2

I'm going to need to go through the same process for production but,
unless someone has any recommendations, I'll just repoint the server
addresses and run it again.

Cheers,
James

On Apr 4, 11:58 am, "Marc Esher" <marc.es...@gmail.com> wrote:
> or do you want even simpler than that, i.e. no looping. Like, you know
> you only have two servers, and you just want to do this:
>
> (in pseudocode):
>
> DeployToServer("\\my-server")
> DeployToServer("\\my-server2")
>
> On Fri, Apr 4, 2008 at 6:55 AM, Marc Esher <marc.es...@gmail.com> wrote:
> > Clarkee, when you say "how do you deploy to more than one server", are
> > you talking about how to use ant to straight-up copy files to multiple
> > servers?
>
> > like, in pseudocode, do you want to do this:
>
> > set servers = "\\my-server1\,\\my-server2,\\my-server3"
> > for each server
> > copy all files from this dir into {server}\thatdir
>
> > ??
>
> > Marc
>

Marc Esher

unread,
Apr 4, 2008, 7:49:50 AM4/4/08
to cfeclip...@googlegroups.com
Cool. I whipped this up really quick. The important thing here, I
think, is using macrodef. i did it for the "deploy" task, but not for
the "clean" task. but the clean task could really use it... so if you
want to play with macrodef yourself, just follow the pattern I used
for copyToServer.

here goes:

<project name="macrodef" basedir=".">

<target name="init">
<property name="server1" location="spoofserver1" />
<property name="server2" location="spoofserver2" />
<property name="src" location="." />
</target>

<target name="clean" depends="init">
<!-- this sucks... duplication -->
<echo message="deleting target directories and recreating" />
<delete dir="${server1}" includeemptydirs="true" />
<delete dir="${server2}" includeemptydirs="true" />
<mkdir dir="${server1}" />
<mkdir dir="${server2}" />
</target>

<target name="deploy" depends="clean">
<copyToServer todir="${server1}" />
<copyToServer todir="${server2}" />
</target>

<macrodef name="copyToServer">
<attribute name="todir" default="." />
<sequential>
<echo message="Copying ${src} to @{todir}" />
<!-- your existing copy stuff would go here! -->
<copy todir="@{todir}" preservelastmodified="true" includeEmptyDirs="false">
<fileset dir="${src}" includes="**/*.*" />
</copy>
</sequential>
</macrodef>

</project>

Priest, James (NIH/NIEHS) [C]

unread,
Apr 4, 2008, 8:01:52 AM4/4/08
to cfeclip...@googlegroups.com
James - FWIW - I have a bunch of stuff on my Wiki related to Ant...

http://www.thecrumb.com/wiki/Ant

In my main build script I use the input task to prompt me to select a
server to deploy to:


<input message="Where do you want to deploy to?"
validargs="${deploy.list}"
addproperty="deploy.server"
defaultvalue="${deploy.default}"/>

This pulls a list of my servers (deploy.list) and when selected writes
that to the deploy.server property.

I do the same thing with SVN - allowing the user to select a server and
what revision they want to deploy:

<input message="Enter revision (HEAD or number: Hit &lt;enter&gt; to
use default value of HEAD)" addproperty="svn.revision"
defaultvalue="HEAD" />


My Ant page on my Wiki is under a bit of construction but most links
work and if you run into anything that's broken just let me know and I
can get you what you need.

Jim

Marc Esher

unread,
Apr 4, 2008, 8:04:05 AM4/4/08
to cfeclip...@googlegroups.com
Also, FWIW, Jim's ANT page is the first place i go when i don't know
how to do something and can't find it in the manual. it's chock full
of great original content and great external links.

Clarkee21

unread,
Apr 4, 2008, 8:21:03 AM4/4/08
to CFEclipse Users
Fantastic guys, thanks for all your efforts. I only started with ANT
yesterday afternoon and can already see this solving quite a few
boring routine jobs we do here. We don't do structured builds yet but
just showing our Lead Developer how long it took me upload 120+ files
to these two servers using ANT has set off a light bulb in both our
heads :-)

Most of my learning has actually been from Andy Jarret's blog entries
and your Wiki Jim so good to know I'm looking in the right places.

Again thank you ;-)

James

On Apr 4, 1:04 pm, "Marc Esher" <marc.es...@gmail.com> wrote:
> Also, FWIW, Jim's ANT page is the first place i go when i don't know
> how to do something and can't find it in the manual. it's chock full
> of great original content and great external links.
>
> On Fri, Apr 4, 2008 at 8:01 AM, Priest, James (NIH/NIEHS) [C]
>

Priest, James (NIH/NIEHS) [C]

unread,
Apr 4, 2008, 8:25:55 AM4/4/08
to cfeclip...@googlegroups.com
One thing you may want to take a look at is my recent download for the
CFMeetup preso I gave:

http://www.thecrumb.com/files/ant-presentation.zip

It includes a /jar directory which contains all the extra task .jar
files that I've found useful. I'm working on improving that even more -
just so it's super easy to grab all those and get running without
scouring the net trying to figure out what to download...

Jim

Clarkee21

unread,
Apr 8, 2008, 8:34:47 AM4/8/08
to CFEclipse Users
Sorry one more question as I can't seem to find anything online about
this:

Say I get a user to input the name of the server. How can I then use
that value to reference the property which holds the server path?

I've got the following code at the moment but it doesn't work:

<!-- Dev server location -->
<property name="server.cfdev" value="\\CFDEV\c$\Inetpub\wwwroot
\cfusion.war\" />
<!-- Test server location(s) -->
<property name="server.cftest1" value="\\CFTEST1\c$\Inetpub
\wwwroot\cfusion.war\" />
<property name="server.cftest2" value="\\CFTEST2\c$\Inetpub\wwwroot
\cfusion.war\" />
<!-- Production server location(s) -->
<property name="server.cfprod1" value="\\CFPROD1\c$\Inetpub
\wwwroot\cfusion.war\" />
<property name="server.cfprod2" value="\\CFPROD2\c$\Inetpub\wwwroot
\cfusion.war\" />

<input validargs="cftest1,cftest2,cfprod1,cfprod2"
addproperty="deploy.server" message="Select a server" />
<property name="myServer" value="server.${deploy.server}" />

<echo message="${myServer}" />


It's almost like I need an evaluate() method of some kind to make that
myServer property value into the value of the specified server.

Cheers,
James

Priest, James (NIH/NIEHS) [C]

unread,
Apr 8, 2008, 8:58:59 AM4/8/08
to cfeclip...@googlegroups.com
Here's how I do that:

<input message="Where do you want to deploy to?"
validargs="${deploy.list}"
addproperty="deploy.server"
defaultvalue="${deploy.default}"/>

In an external property file I have my servers defined:
# enter locations you would like to deploy to deploy.server
deploy.list = KIRK, SPOCK
deploy.default = KIRK

Depending on what they pick I then include a server.property file which
has properties defined for just that server which I use to define my
paths where I'm going to copy files to:
<property file="${deploy.server}.properties"/>


Kirk.properties:

# properties for deployment to //kirk
deploy.uncpath = //kirk/${project.name}$
deploy.reseturl =
https://appdev.niehs.nih.gov/projectname/index.cfm?reset=true

More on my wiki:
http://www.thecrumb.com/wiki/ant#my_ant_buildfile_scripts

Jim

> -----Original Message-----
> From: Clarkee21 [mailto:Clar...@gmail.com]
> Sent: Tuesday, April 08, 2008 8:35 AM
> To: CFEclipse Users
> Subject: Re: ANT Permission problems
>
>

Clarkee21

unread,
Apr 8, 2008, 9:32:24 AM4/8/08
to CFEclipse Users
Oh if only it was as simply as CF :-).

That's great though Jim I'll give it a bash.

On Apr 8, 1:58 pm, "Priest, James (NIH/NIEHS) [C]"
<Prie...@niehs.nih.gov> wrote:
> Here's how I do that:
>
> <input message="Where do you want to deploy to?"
> validargs="${deploy.list}"
> addproperty="deploy.server"
> defaultvalue="${deploy.default}"/>
>
> In an external property file I have my servers defined:
> # enter locations you would like to deploy to deploy.server
> deploy.list = KIRK, SPOCK
> deploy.default = KIRK
>
> Depending on what they pick I then include a server.property file which
> has properties defined for just that server which I use to define my
> paths where I'm going to copy files to:
> <property file="${deploy.server}.properties"/>
>
> Kirk.properties:
>
> # properties for deployment to //kirk
> deploy.uncpath = //kirk/${project.name}$
> deploy.reseturl =https://appdev.niehs.nih.gov/projectname/index.cfm?reset=true
Reply all
Reply to author
Forward
0 new messages