The JavaTM Web Services Tutorial
Home
TOC
PREV TOP NEXT

Setting Up

Before you start developing the example application, you should follow the instructions in this section and in About the Examples.

Getting the Example Code

The source code for the example is in <JWSDP_HOME>/docs/tutorial/examples/gs/, a directory that is created when you unzip the tutorial bundle. If you are viewing this tutorial online, you can download the tutorial bundle from:

http://java.sun.com/webservices/downloads/webservicestutorial.html
 

In this example application, the source code directories are organized according to the "best practices approach to web services programming", which is described in more detail in the file <JWSDP_HOME>/docs/tomcat/appdev/deployment.html. Basically, the document explains that it is useful to examine the runtime organization of a web application when creating the application. A web application is defined as a hierarchy of directories and files in a standard layout. Such a hierarchy can be accessed in its unpacked form, where each directory and file exists in the file system separately, or in a packed form known as a Web Application aRchive, or WAR file. The former format is more useful during development, while the latter is used when you distribute your application to be installed.

To facilitate creation of a WAR file in the required format, it is convenient to arrange the files that Tomcat uses when executing your application in the same organization as required by the WAR format itself. In this example application at <JWSDP_HOME>/docs/tutorial/examples/gs/, which is the root directory for the source code for this application. The application consists of the following files that are either in the /gs directory or a subdirectory of /gs.

A key recommendation of the Tomcat Application Developer's Manual is to separate the directory hierarchy containing the source code from the directory hierarchy containing the deployable application. Maintaining this separation has the following advantages:

As discussed in Creating the Build and Deploy File for Ant, the Ant development tool makes the creation and processing of this type of directory hierarchies relatively simple.

The rest of this document shows how this example application is created, built, deployed, and run. If you would like to skip the information on creating the example application, you can go directly to the sections describing how to build, deploy, and run the example application, starting with Building the Getting Started Application Using Ant.

Checking the Environment Variables

The installation instructions for the Java Web Services Developer Pack explain how to set the required environment variables. Please verify that the environment variables in the file setenv.sh (Unix environment) or setenv.bat (Microsoft Windows environment) in the bin directory of your Java WSDP installation have been set to the values noted in the following table.

Table 3-1 Required Environment Variables 
Environment Variable
Value
JAVA_HOME
The location of the Java 2 Platform, Standard Edition (J2SE) installation.
JWSDP_HOME
The location of the Java Web Services Developer Pack installation.

Also, make sure that you have included the bin directories of the Java Web Services Developer Pack and J2SE installations at the front of your path statement.

Creating the Build Properties File

In order to invoke many of the Ant tasks, you need to put a file named build.properties in your home directory. On the Solaris operating system, your home directory is generally of the format /home/your_name. In the Windows operating environment (for example on Windows 2000), your home directory is generally C:\Documents and Settings\yourProfile.

The build.properties file contains a user name and password that match the user name and password set up during installation. The user name and password that you entered during installation of the Java WSDP are stored in <JWSDP_HOME>/conf/tomcat-users.xml.

For security purposes, the Tomcat Manager application verifies that you (as defined in the build.properties file) are a user who is authorized to install and reload applications (as defined in tomcat-users.xml) before granting you access to the server.

If you have not already created a build.properties file in your home directory, do so now. The file will look like this:

username=your_name password=your_password

The tomcat-users.xml file, which is created by the installer, looks like this:

<?xml version='1.0'?>	
<tomcat-users>	
<role rolename="admin"/>	
<role rolename="manager"/>	
<role rolename="provider"/>	
<user username="your_name" password="your_password"	
     roles="admin,manager,provider"/>	
</tomcat-users>
 
Home
TOC
PREV TOP NEXT