Home
TOC Index |
Deploying the Application
In this release of the Java WSDP there are two options for deploying an application: using the
Ant
tool and using the Application Deployment Tool. For this example, both options require that the Tomcat be started. For further information on deploying Web applications, please read Deploying Web Applications.Starting Tomcat
To start Tomcat, type the following command in a terminal window.
<JWSDP_HOME
>/bin/startup.sh (Unix platform) <JWSDP_HOME
>\bin\startup (Microsoft Windows)The startup script starts the task in the background and then returns the user to the command line prompt immediately. The startup script does not completely start Tomcat for several minutes.
Note: The startup script for Tomcat can take several minutes to complete. To verify that Tomcat is running, point your browser tohttp://localhost:8080
. When the Tomcat splash screen displays, you may continue. If the splash screen does not load immediately, wait up to several minutes and then retry. If, after several minutes, the Tomcat splash screen does not display, refer to the troubleshooting tips in "Unable to Locate the Server localhost:8080" Error.
Documentation for Tomcat can be found at <
JWSDP_HOME
>/docs/tomcat/index.html.
Installing the Application using Ant
A Web application is defined as a hierarchy of directories and files in a standard layout. In this example, the hierarchy is accessed in an unpacked form, where each directory and file exists in the file system separately. This section discusses deploying your application using the
Ant
tool defined in Creating the Build and Deploy File for Ant.A context is a name that gets mapped to the document root of a Web application. The context of the GSApp application is /GSAPP. The request URL http://localhost:8080/GSApp/index.html retrieves the file index.html from the document root. To install an application to Tomcat, you notify Tomcat that a new context is available.
You notify Tomcat of a new context with the
Ant
install
task from thebuild.xml
file. TheAnt
install
task does not require Tomcat to be restarted, but an installed application is also not remembered after Tomcat is restarted. To permanently deploy an application, see Deploying Web Applications.The Ant install task tells a Tomcat manager application to install an application at the context specified by the path attribute and the location containing the Web application files. Read Installing Web Applications for more information on this procedure. The steps for deploying this Web application follow.
- In a terminal window, go to the
GSApp/
directory.- Type the following command to deploy the Web application files:
ant install
- This command copies the Web client file,
index.jsp
, to<
JWSDP_HOME
>/docs/tutorial/examples/GSApp/build/
and copies the JavaBeans component class file,ConverterBean.class
, to<
JWSDP_HOME
>/docs/tutorial/examples/gs/build/WEB-INF/classes/converterApp/
.Deploying the Application Using deploytool
The Application Deployment Tool, referred to hereafter as
deploytool
for ease of reference, is included in this release of the Java WSDP. This section discusses usingdeploytool
to create a Web Application aRchive (WAR) file for deploying your application and handling security issues. To deploy the application usingdeploytool
, follow these steps.
- Start Tomcat (if it is not already running).
- Start
deploytool
, a command line tool that is located in thebin
directory of your Java WSDP installation.<JWSDP_HOME
>/bin/deploytool- In the Set Tomcat Server dialog, enter a valid user name and password. These will have been set up when the Java WSDP was installed, or can be set up using
admintool
. Information on setting up users withadmintool
can be read at Using admintool.- Select OK to complete the deployment.
- Select File.
- Select New Web Application.
The New Web Application wizard displays. This wizard will help package the Web application into a Web ARchive (.WAR) file to define individual Web components and to generate a deployment descriptor for the Web application. We will use the wizard identify the files in the Web application and to identify any Web components to uniquely identify in the deployment descriptor for the application.
Creating the WAR File and Identifying Files in the Web Application
To create the WAR file and tell the New Web Application wizard which files it should contain, follow these steps.
- Select Next from the Introduction page.
- The Create New Stand-Alone WAR Module section on the WAR File page of the wizard displays.
- Select the Browse button next to the Module File Name field and select the path for the directory in which to create this file, for example, the root directory where the example application is generated by
Ant
, which is the<
JWSDP_HOME
>/docs/tutorial/examples/GSApp
directory.- Enter the name for the WAR file, for example, GSApp.war, and select the Choose Module File button.
- Enter a value in the WAR Display Name field, for example,
GSApp
.- Select the Edit button in the Contents box to add files to the WAR file.
- Select
ConverterBean.class
from the<
JWSDP_HOME
>/docs/tutorial/examples/GSApp/build/WEB-INF/classes/converterApp
directory, then select the Add button to add this file to the archive. This directory is where this file was based on thebuild.xml
script.- Select
index.jsp
from the<
JWSDP_HOME
>/docs/tutorial/examples/GSApp/build/WEB-INF
directory, then select the Add button to add this file to the archive. This directory is where this file was based on thebuild.xml
script.- Select OK to exit the Edit Contents dialog.
- Select the Next button to continue.
Choosing the Component Type
This page of the wizard is the Choose Component Type page. On this page, we will select JSP page as the type of component we are creating.
Set the Component Properties
This page of the wizard is the Component General Properties page. On this page, we will select the JSP file.
- Select
index.jsp
from the JSP Filename list.- Select Finish.
- Select File, then select Save to save the WAR file.
The WAR file is created and the contents of the file are displayed on the General tab of the Application Deployment Tool.
Deploy the Application
Once the WAR file is created, we can deploy the application. To do this, follow these steps. When you choose the
deploy
operation, it copies the WAR it creates to Tomcat and notifies Tomcat of the new context. You can only deploy tolocalhost
withdeploytool
.The Deployment console displays. You can Close the window if you'd like.
Viewing the Deployment Descriptor
When you deploy the application using
deploytool
, a deployment descriptor is generated. To view the deployment descriptor, choose Tools->Descriptor Viewer from thedeploytool
menu. The simple deployment descriptor generated for this example from the preceding steps looks like this:<?xmlversion="1.0"encoding="UTF-8"?> <!DOCTYPEweb-appPUBLIC'- //SunMicrosystems,Inc.//DTDWebApplication2.3//EN''http://java. sun.com/dtd/web-app_2_3.dtd'> <web-app> <display-name>GSApp</display-name> <servlet> <servlet-name>index</servlet-name> <display-name>index</display-name> <jsp-file>/index.jsp</jsp-file> </servlet> <session-config> <session-timeout>30</session-timeout> </session-config> </web-app>
Home
TOC Index |
This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.
All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.