Ant script management glassfish

Source: Internet
Author: User
Tags glassfish

Environment glassfish2.x, Windows 7 or Windows Server 2008

This script can be deployed to disable and start the glassfish service.

Note that there is a bug in glassfish2 at startup. You must set the system environment variable old_launcher to true (if not, add one)

Official Document reference:

Http://docs.oracle.com/cd/E19316-01/820-4336/6nfqd2b2e/index.html

Paste the script below,

<project name="MyDeploy" default="dist" basedir=".">  <description>    Deploying web application on GlassFish2.x  </description>  <!-- set global properties for this build -->  <property name="glassfish.host" value="127.0.0.1" />   <property name="glassfish.user" value="admin" />   <property name="glassfish.passwordfile" location="pwd" />   <!-- password file is a text file with line: AS_ADMIN_PASSWORD=[i]your_glassfish_admin_password[/i]  -->   <property name="glassfish.deployer.dir" value="c:/portal/glassfish" /> <!--here use your directory -->   <property name="warfile" value="d:/your.war"/>  <property name="webapp.name" value="yourweb"/>  <property name="webapp.context" value="yourweb"/>  <path id="glassfish.deployer">     <fileset dir="${glassfish.deployer.dir}\lib" >           <include name="*.jar"/>     </fileset>               </path>   <target name="deploy" description="generate the distribution" >    <!-- Create the distribution directory -->    <mkdir dir="${dist}/lib"/>    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->    <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>  </target>  <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" />   <taskdef       name="sun-appserv-admin"       classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.AdminTask"       classpathref="glassfish.deployer" />   <target name="glassfish-stop">    <echo level="info"> Begin to stop glassfish server now! </echo>     <sun-appserv-admin   asinstalldir="${glassfish.deployer.dir}" explicitcommand="stop-domain domain1">      <server   host="${glassfish.host}"   user="${glassfish.user}"   passwordfile="${glassfish.passwordfile}" />     </sun-appserv-admin>               <echo level="info"> done! </echo>     <tstamp>       <format property="end_time" pattern="yyyy-MM-dd HH:mm:ss.SSS" locale="pl"/>     </tstamp>     <echo level="info">Glassfish stopped at ${end_time}</echo>   </target>  <target name="glassfish-start">    <echo level="info"> Begin to start glassfish server now! </echo>     <sun-appserv-admin asinstalldir="${glassfish.deployer.dir}" explicitcommand="start-domain domain1">      <server   host="${glassfish.host}"   user="${glassfish.user}"   passwordfile="${glassfish.passwordfile}" />     </sun-appserv-admin>               <echo level="info"> done! </echo>     <tstamp>       <format property="end_time" pattern="yyyy-MM-dd HH:mm:ss.SSS" locale="pl"/>     </tstamp>     <echo level="info">Glassfish started at ${end_time}</echo>   </target>  <target name="glassfish-deploy" >       <echo level="info">Deploing WAR file on the glassfish remote server ... </echo>     <sun-appserv-deploy file="${warfile}" name="${webapp.name}" contextroot="${webapp.context}" upload="false" force="true" verify="false" 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> </project>

Glassfish 3.1.2 A module should be installed in the Web profile: glassfish-ant-Tasks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.