Deploying WAR Files
From Stax
If you have an a Java web application packaged as a WAR file, you can use the Stax Deploy ANT task from the Stax SDK to deploy your WAR file to the Stax Cloud using an ANT script.
The Stax Deploy ANT task only supports deploying EAR files, and does not directly support WAR files, but you can use an ANT task to build a simple EAR file from your WAR file. You will also need to include a stax-application.xml file in your application. The easiest way to generate this file, is to use the SDK stax create command to create a new application, and then just copy the application's stax-application.xml file from the conf directory.
Using ANT to deploy applications
Below is an example ANT script you can use to deploy your WAR files to Stax. To use this script, do the following:
- Install the Stax SDK and set the STAX_HOME environment variable as directed
- Install ANT
- Copy the ANT build.xml section below, and save it to a file called build.xml
- Update the bold values in the build.xml as appropriate for your application
- Run the ant deploy command to deploy your application
ANT build.xml
<project name="stax-build" default="dist" basedir=".">
<description>
Stax application build file
</description>
<property environment="env" />
<property name="stax.home" location="${env.STAX_HOME}" />
<property name="dist" location="dist" />
<property name="deploy.file" location="${dist}/stax-deploy.ear" />
<property name="war.file" location="path_to_your_war_file" />
<property name="stax.appxml" location="path_to_your_stax_application_xml" />
<property name="stax.username" value="your_stax_username" />
<property name="stax.password" value="your_stax_password" />
<path id="staxtasks.classpath">
<fileset dir="${stax.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${stax.home}/groovy/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="clean" description="clean up">
<delete dir="${dist}" />
</target>
<target name="dist" description="generate the distribution">
<mkdir dir="${dist}" />
<mkdir dir="${dist}/conf" />
<copy file="${war.file}" tofile="${dist}/webapp.war" />
<copy file="${stax.appxml}" tofile="${dist}/conf/stax-application.xml" />
<delete file="${dist}/conf/application.xml" />
<echo file="${dist}/conf/application.xml"><![CDATA[<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN" "http://java.sun.com/j2ee/dtds/application_1_2.dtd">
<application>
<module>
<web>
<web-uri>webapp.war</web-uri>
<context-root></context-root>
</web>
</module>
</application> ]]>
</echo>
<jar destfile="${deploy.file}">
<metainf dir="${dist}/conf">
<include name="stax-application.xml"/>
<include name="application.xml"/>
</metainf>
<zipfileset dir="${dist}">
<include name="webapp.war" />
</zipfileset>
</jar>
</target>
<target name="deploy" depends="dist" description="deploy the distribution to Stax">
<fail message="stax.username is not set" unless="stax.username" />
<fail message="stax.password is not set" unless="stax.password" />
<taskdef name="deploy" classname="com.staxnet.ant.DeployTask" classpathref="staxtasks.classpath"/>
<deploy deployfile="${deploy.file}" username="${stax.username}" password="${stax.password}" />
</target>
</project>
stax-application.xml
The stax-application.xml file is the deployment descriptor for customizing your application deployment when running on Stax. When your application is deployed, Stax will look for this file in the META-INF directory of your deployment archive (so it should be packaged next to the standard J2EE application.xml)
If you need to define a stax-application.xml file from scratch, here is the basic structure:
<stax-application> [Copy/paste the stax-application.xml settings from your Stax database's panel here] </stax-application>
