DevPortal

How do I Deploy Applications Using ANT Handler?


Table of Contents


How do I Deploy Applications Using ANT Handler?

Developers who regularly use ANT to manage application development and deployment can use the Pramati ANT Handler to prepare and distribute applications on local and remote Pramati Server instances. The following sections describe how to install ANT handler, an example that uses it to deploy an application, and the Server commands.

Note: For more information on ANT, visit http://jakarta.apache.org/ant/index.html.

ANT is typically used to build application classes. Web components get packaged in a .war, enterprise beans are packaged in a .jar, and .wars and .jars are packaged in a .ear. ANT enables this process to be automated, without any intervention.

The XML file, or the build.xml that contains the instructions, is made up of targets. Each target has a task or set of tasks associated with it. A custom target that handles remote server tasks is provided as part of the ANT integration in Pramati Server. These remote tasks include commands Deploy, Prepare and Start, and Stop and Remove.

How do I use ANT Handler?

To use the ANT handler, the following jars are required:

Table 1: .jar files needed to use the ANT handler

FileDescription
pramati_ant.jar Is the Pramati ANT Handler that enables remote shell commands from a customized ANT task.
pramati_client_all.jarIncludes all the classes that are required for Java clients to access the Server.
  1. These jar files are located at <install_dir>/server/lib/pramati_client/.
  2. Set <ant_home _moz-userdefined=""/> environment variable to the directory containing the bin and lib directories of ANT.
  3. Copy pramati_ant.jar under <ANT_Home>/lib. Essentially, pramati_ant.jar files must be specified in the ANT classpath. Only the archives that are in a ready-to-deploy state, that is, the archives that have all the required deployment descriptors, can be deployed or started using the Pramati ANT handler.
  4. Ensure that the Server is started and run the ANT script using the command:<path>ant -buildfile <ANT script filename>

Example: Using the sample ant.xml to Perform a Server Task:

Type D:\ant\ant.xml prepare_app. This prepares the application BankDesk.ear on the server as specified in the ant.xml (see sample below).

What are the Various Pramati ANT Handler Commands?

All command operations in the Pramati Server Remote Shell are executable as an ANT task on Pramati Server. Here is the list of commands:

Table 2: ANT handler commands

CommandDescription
preparePrepares the application mentioned in the commands attribute.
startStarts the application mentioned in the commands attribute if it is already deployed.
deployPrepares and starts the application mentioned in the commands attribute.
stopStops the running application mentioned in the commands attribute.
removeRemoves application archive from Server installation directory. The application has to be re-prepared.

How do I Connect to Server?

Defining a task requires connection to the Server. Server can be contacted by giving its IP, port, realm, user, and password. These are specified as attributes of the task as shown here:
ip="127.0.0.1"
port="9191"
realm="system"
user="root"
password="pramati"
Specify the properties as listed in the table below when you need to connect to the Server:

Table 3: Server attributes

AttributeDescriptionMandatory
ipIs the address of the remote server. Yes
portIs the port on which the server is running.Yes
realmIs the security realm of the remote server.Yes
userIs the username to login to the remote server.Yes
passwordIs the password to login to the remote server.Yes
waitWaits for commands to be executed. Default is True.No
classpathIs the classpath required to execute the task.No
commandsAre the commands to be executed.Yes
verboseGenerates messages when the task executes. The default value for this attribute is False.No

Sample XML

A sample XML is provided below. With this XML, you can prepare, start, stop, and remove the sample application BankDesk.ear that is shipped with Pramati Server.
<project name="AntShell" default="servertasks">
<taskdef name="pramati" classname="com.pramati.AntTaskHandler"/>

<target name="servertasks" depends="prepare_app,start_app,stop_app,remove_app"/>
<target name="prepare_app">
<pramati verbose="true"
    ip ="localhost"
    port ="9191"
    realm ="system"
    user ="root"
    password ="pramati"
    wait ="true"
    classpath ="D:\ant\lib\pramati_client_all.jar"
    commands ="prepare D:\PServer50\server\samples\ejb11\BankDesk\ear\BankDesk.ear"
/>
</target>
<target name="start_app">
<pramati verbose="true"
     ip ="localhost"
     port ="9191"
     realm ="system"
     user ="root"
     password ="pramati"
     wait = "true"
     classpath ="D:\ant\lib\pramati_client_all.jar"
     commands ="start BankDesk.ear"
/>
<target>
<target name="stop_app">
  <pramati verbose="true"
     ip ="localhost"
     port ="9191"
     realm ="system"
     user ="root"
     password ="pramati"
     wait ="true"
     classpath ="D:\ant\lib\pramati_client_all.jar"
     commands ="stop BankDesk.ear"
/>
</target>
<target name="remove_app">
  <pramati verbose="true"
     ip ="localhost"
     port ="9191"
     realm ="system"
     user ="root"
     password ="pramati"
     wait ="true"
     classpath ="D:\ant\lib\pramati_client_all.jar"
     commands ="remove BankDesk.ear"
/>
<target>
</project>
</pre>

Note: The classpath attribute inside <pramati _moz-userdefined=""> element should definitely include pramati_client_all.jar.<pramati>.

© Pramati Technologies 2007 Runs on Pramati Server | Feedback | Legal