...
With this command, ant will use the targets defined in the jboss-build.xml
file to build the College Fest application and deploy it to the JBoss server. Take a special look at <target name="deploy" ...>, here is where the jboss-build.xml
tell ant where to deploy the WAR file. The following example shows the definitions in the jboss-build.xml
file.
Code Block | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
<?xml version="1.0"?> <!-- build file for building a war --> <project name="build" default="war" basedir="."> <property file="build.properties"/> <property name="src.dir" value="src"/> <property name="dest.dir" value="bin"/> <target name="clean" description="Delete all generated files"> <echo message="Deleting bin directory" /> <delete dir="bin" /> </target> <target name="compile"> <mkdir dir="${dest.dir}"/> <javac srcdir="${src.dir}" destdir="${dest.dir}"> <classpath path="${java.home}/lib/tools.jar"/> <classpath path="${j2ee.home}/lib/j2ee.jar"/> </javac> </target> <target name="war" depends="compile"> <war destfile="college_fest.war" webxml="WEB-INF/web.xml"> <zipfileset dir="jsp" prefix="jsp"/> <zipfileset dir="pix" prefix="pix"/> <classes dir="${dest.dir}"/> <webinf dir="WEB-INF" /> </war> </target> <target name="deploy" depends="war"> <copy file="college_fest.war" todir="${jboss.server}/deploy"/> </target> <target name="undeploy"> <delete file="${jboss.server}/deploy/college_fest.war"/> </target> </project> |
The war created by the ant build contains a JBoss specific deployment descriptor, the jboss-web.xml
file in the WEB-INF
directory of the WAR is shown in the following example.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8"?> <jboss-web> <context-root>college_fest</context-root> <context-priority-classloader> false </context-priority-classloader> </jboss-web> |
...
To test the application, open a Web browser and access the following URL:
http://localhost:8080/college_fest
You should see the Welcome screen where you can login with your name and college. When you enter your name a college and click Submit you will see a message at the end on the page stating your name with a link to "Click here" to enter the site. Browse the site and check the options, at this point the College Fest application is configured and running.
...
Download and install Geronimo from the following URL:
http://geronimo.apache.org/downloads.html
The release notes available there provide clear instructions on system requirements and how to install and start Geronimo. Throughout the rest of this article we will refer to the Geronimo installation directory as <geronimo_home>.
...
Note |
---|
The following geronimo-web.xml was generated using the J2G tool. |
Code Block | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1" xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1" xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"> <sys:environment> <sys:moduleId> <sys:groupId>j2g</sys:groupId> <sys:artifactId>web-module</sys:artifactId> <sys:version>1.0</sys:version> <sys:type>war</sys:type> </sys:moduleId> <sys:dependencies/> </sys:environment> <context-root>college_fest</context-root> </web-app> |
...
Last time you built the College Fest sample application it was configured for ant to use the jboss-build.xml
file instead of the default build.xml
. The following example shows the content of the default build.xml
file.
Code Block | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
<?xml version="1.0"?> <!-- build file for building a war --> <project name="build" default="war" basedir="."> <property file="build.properties"/> <property name="src.dir" value="src"/> <property name="dest.dir" value="bin"/> <target name="clean" description="Delete all generated files."> <echo message="Deleting bin folder" /> <delete dir="bin"/> </target> <target name="compile"> <mkdir dir="${dest.dir}"/> <javac srcdir="${src.dir}" destdir="${dest.dir}"> <classpath path="${java.home}/lib/tools.jar"/> <!--classpath path="${j2ee.home}/lib/j2ee.jar"/--> <classpath path="${geronimo.home}/repository/org/apache/geronimo/specs/geronimo-servlet_2.5_spec/1.1/geronimo-servlet_2.5_spec-1.1.jar" /> </javac> </target> <target name="war" depends="compile"> <war destfile="college_fest.war" webxml="WEB-INF/web.xml"> <zipfileset dir="jsp" prefix="jsp"/> <zipfileset dir="pix" prefix="pix"/> <classes dir="${dest.dir}"/> <webinf dir="WEB-INF" /> </war> </target> </project> |
...
Once the application is deployed, open a Web browser and access the following URL:
http://localhost:8080/college_fest/
Repeat the steps you did when Testing the application on the JBoss environment.
...