I had the same problem and google didn't help, so I installed glassfish (v 2.1.b60e) provisionally on my dev machine and investigated what jars are used to deploy WAR file on a (remote) server machine with glassfish. My dev machine runs on window$, but it should work on Linux too.
All you have to have in order to use ant is a directory, (e.g. d:\glassfish-deployer) with the following directory structures and files:
.\bin
.\config
.\config\asenv.bat
.\config\asenv.conf
.\lib
.\lib\admin-cli.jar
.\lib\appserv-ext.jar
.\lib\javaee.jar
.\lib\appserv-admin.jar
.\lib\appserv-launch.jar
.\lib\jmxremote_optional.jar
.\lib\appserv-deployment-client.jar
.\lib\appserv-rt.jar
.\lib\sun-appserv-ant.jar
.\build.properties
.\registry.properties
As you can see, there are some non-jar files and empty .\bin directory. These files can be empty or have any content, but they have to exist to cheat the "deployer" classes (to let them think we have fully installed glassfish)
Once you prepared the fake glassfish directory (it takes about 22 MB), you can create build.xml and use ant to deploy WARs on a remote glassfish server.
Here is a fragment of the build.xml file I use:
<property name="glassfish.host" value="[i]to_be_filled[/i]" />
<property name="glassfish.user" value="admin" />
<property name="glassfish.passwordfile" value="[i]to_be_filled[/i]" />
<!-- password file is a text file with line: AS_ADMIN_PASSWORD=[i]your_glassfish_admin_password[/i] -->
<property name="glassfish.deployer.dir" value="d:\glassfish-deployer" /> <!--here use your directory -->
<path id="glassfish.deployer">
<fileset dir="${glassfish.deployer.dir}\lib" >
<include name="*.jar"/>
</fileset>
</path>
<taskdef
name="sun-appserv-deploy"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask"
classpathref="glassfish.deployer" />
<taskdef
name="sun-appserv-undeploy"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.UndeployTask"
classpathref="glassfish.deployer" />
<target name="glassfish-deploy" depends="create-war" >
<echo level="info">Deploing WAR file on the glassfish remote server ... </echo>
<sun-appserv-deploy
file="${warfile}"
name="${webapp.name}"
contextroot="${webapp.name}"
upload="true"
force="true"
verify="true"
precompilejsp="false"
asinstalldir="${glassfish.deployer.dir}" >
<server
host="${glassfish.host}"
user="${glassfish.user}"
passwordfile="${glassfish.passwordfile}" />
</sun-appserv-deploy>
<echo level="info"> done! </echo>
<tstamp>
<format property="end_time" pattern="yyyy-MM-dd HH:mm:ss.SSS" locale="pl"/>
</tstamp>
<echo level="info">WAR file deployed at ${end_time}</echo>
</target>
<target name="glassfish-undeploy" >
<sun-appserv-undeploy
name="${webapp.name}"
asinstalldir="${glassfish.deployer.dir}">
<server
host="${glassfish.host}"
user="${glassfish.user}"
passwordfile="${glassfish.passwordfile}" />
</sun-appserv-undeploy>
</target>
After you create glassfish.passwordfile and set the required properties, you can use:
[i]ant glassfis-deploy[/i] and [i]ant glassfis-undeploy[/i]
Of course, you can define and call others targets asant can run (like stop, reload), but if you need it, I'm sure you can do it without help.
[Message sent by forum member 'zdroyer' (zdroyer)]
http://forums.java.net/jive/thread.jspa?messageID=353546