Previous Next Contents Index


Chapter 2

Deploying and Upgrading Applications

This chapter describes how to deploy and upgrade applications on a Netscape Application Server machine.

The following topics are included in this chapter:


Deploying an Application Using Deployment Manager
You can deploy an application using the Deployment Manager, a separate tool accessible from Netscape Application Server (NAS) Administrator or from Netscape Application Builder (NAB). When you deploy an application, the Deployment Manager installs all the application's files and registers all its components on the destination server, a NAS machine. An application must be deployed before it can be used.

Generally, a developer creates an application on a development machine using tools such as NAB, then deploys that application from the development machine to an application server using the Deployment Manager. NAS administrators, on the other hand, might use the Deployment Manager to both download an application from a NAS machine and subsequently redeploy that application to one or more applications servers.

Specifying Application Directories Before you deploy an application, you can change the application root directories that specify where the Java Server or C++ Server processes should look for application component files such as query files and template files. By referencing application root directories, you can move these components around without having to rewrite application code. If you do not specify particular root directories, application files are deployed to default directories.

The Java Server and C++ Server processes use root directories to find application components when those component are needed. For example, after a result set is returned from the database, the application most likely uses a template to format the data. The process, whether Java Server or C++ Server, scans the template root directory or directories to find the specified template file referenced by the application or query file.

To specify application root directories, perform the following steps:

  1. From the NAS Administrator toolbar, click the Application button to open the Application window.
  2. In the left pane of the Application window, select the NAS machine whose application root directories you want to change.
  3. In the right pane of the Application window, use the text boxes to modify root directories for the specified application components as shown in the following figure:
  4. Click Apply Changes to save your changes to your NAS machine.
Packaging Application Files for Deployment Before you deploy an application, you must bundle its files into a JAR file or "package." A package contains information about the application files, such as their type and destination directory. You can select specific application files to include in the package or bundle an entire application into a package ready for deployment.

When you later deploy the package, the bundled application files are automatically distributed to their appropriate directories on one or more servers. For example, Java files and query files are automatically sent to the applications directory of your application server. At the same time, web server files, such as HTML templates, are automatically deployed to a user-defined directory on the web server. In addition, the HTML template files that reside on the application server, rather than on the web server, are deployed to their proper directory.

Creating a Package
To create a package, perform the following steps:

  1. Open the Deployment Manager in one of two ways:
  2. From the Deployment Manager's File menu, choose New Project.
  3. Type a name for your project.
  4. If necessary, edit the path to the directory where your JAR file is stored.
  5. Click OK.
  6. From the Edit menu, choose Insert.
  7. Navigate to the directory where application files are stored and select the files to include in the package.
  8. If necessary, edit the application and web file root directories for your application server using the arrow buttons.
  9. Click OK.
  10. Click Yes if the directory contains .class files that will be used in the application.
  11. Once the application files appear in the JAR window as shown in the following figure, create meta-info files such as:
  12. From the File menu, choose Save JAR when all files you want to include in the package appear in the list.
  13. Choose one of the following options:
  14. If your project files require additional action (indicated by red type and an asterisk next to the files in the JAR window), the following dialog box appears:
  15. When saving a JAR file, you can filter .java files out of the package by selecting the corresponding checkbox in the Save JAR File dialog box as shown in the following figure:
  16. Click OK.
Preparing an Enterprise Java Bean for Deployment
You can prepare an Enterprise Java Bean (EJB) to include in your JAR file using the packaging tool. To prepare an EJB, perform the following steps:

  1. From the list of files in the JAR window, select the following three types of classes:
  2. From the EJB menu, choose Create Descriptor.
  3. Click OK when each field is satisfied.
  4. Edit EJB deployment information if necessary using this editor.
  5. From the Deployment Manager's EJB menu, choose Save Descriptor.
  6. Select the type of your EJB: Stateful Session or Stateless Session.
  7. Decide whether to build stubs for the EJB or not.
Editing a Servlet
You can edit any class file in a package as a servlet. The file is then marked as a servlet and an .ntv file is created for it by default.

To edit a servlet, perform the following steps:

  1. From the Servlet menu, choose Edit Info.
  2. Right-click a branch in the tree to edit that branch or remove it.
See Creating a Package for more information about .ntv files.

Editing an EJB's Deployment Descriptor
Deployment descriptors include the declarative attributes associated with an EJB (or bean). These attributes tell an EJB's container how to manage the bean. A container is where an EJB "lives" from its creation to its destruction. The container manages the EJB's life cycle and support services while providing services that allow clients to look up the interfaces of installed EJB classes.

A developer might edit an EJB's deployment descriptor as part of a cycle of developing and testing an application. The editor allows either administrators or developers to easily modify the attributes of EJBs to better work within an application.

You can edit an EJB's deployment descriptor using the editor shown in the following figure:

Editing General Attributes

To edit the General Attributes of an EJB, perform the following steps:

  1. If the editor is not already open, you can open it by right-clicking on a .properties file displayed in the JAR window and choosing Edit Descriptor.
  2. From the File menu, choose Save Descriptor to save your changes.
Editing Control Descriptors

The Control Descriptor tab allows you to configure meta-data for an EJB at deployment time. You can edit transaction isolation levels, transactional attributes, and the mode entry for the bean.

To edit the Control Descriptors for an EJB, perform the following steps:

  1. Click the Control Descriptors tab to display the window as shown in the previous figure.
Editing Environment Properties

See Setting Environment Properties.

Editing Access Control

See Viewing and Editing EJB Access Control.

Deploying an Application After you have created a package using the packaging tool, you use the Deployment Manager to send the package to a NAS machine.

If there is more than one JAR file in a single directory, you can deploy multiple JAR files at the same time from that directory.

To deploy a JAR using the Deployment Manager, perform the following steps:

  1. From the File menu, choose Deploy.
  2. From the list of registered servers, choose a NAS machine to deploy to.
  3. Click Deploy.
Downloading a Package Once an application has been installed on an application server, you can download that application to your machine using the Deployment Manager. When you download an application, you save that application's JAR file to your local machine or another machine on your network.

To download an application, perform the following steps:

  1. From the File menu of the Deployment Manager, choose Download.
  2. Select a server from which to download an application.
  3. From the list of JAR files found on the selected server, select a JAR file to download.
  4. Click Download.
  5. Choose the directory where you will save the JAR file on your local machine or the network.

Deploying Application Files Manually
The Deployment Manager does not allow you to deploy individual application components that are not part of an application. Instead, you can deploy individual application files manual.

This section contains separate procedures for deploying Enterprise Java Beans, servlets and JavaServer Pages (JSPs), and data sources:

Manually Deploying EJBs To deploy an EJB manually, perform the following steps:

  1. Compile the EJB.
  2. Generate stubs and skeletons.
  3. Create a deployment descriptor.
  4. Copy files to NAS.
  5. Register the EJB.
Compile the EJB
Using javac, compile all EJB files including the bean, home interface, and remote interface.

The following example shows what you might type at the command line on Solaris operating systems:

% $GX_ROOTDIR/usr/java/bin/javac ShoppingCartBean.java 
IShoppingCart.java IShoppingCartHome.java
The following example shows what you might type at the command line on Windows NT, using javac in %NASPATH%:

Z:\> C:\Netscape\server4\nas\bin\javac ShoppingCartBean.java 
IShoppingCart.java IShoppingCartHome.java
In these examples, ShoppingCartBean.java is the bean implementation file, IShoppingCart.java is the remote interface, and IShoppingCartHome.java is the home interface.

Generate Stubs and Skeletons
Stubs and skeletons are required by the EJB container and must be deployed with the application files. These stubs and skeletons enable remote communication and allow the container to intercept all bean requests.

Using ejbc, generate stubs and skeletons for your EJB following these examples:

$GX_ROOTDIR/bin/ejbc -sf cart.ShoppingCartBean cart.IShoppingCart 
cart.IShoppingCartHome

Z:\>ejbc -sf cart.ShoppingCartBean cart.IShoppingCart cart.IShoppingCartHome
-sf is used for stateful session beans.

Create a Deployment Descriptor
Deployment descriptors include the declarative attributes associated with an EJB (or bean). These attributes tell an EJB's container how to manage the bean. A container is where an EJB "lives" from its creation to its destruction. The container manages the EJB's life cycle and support services while providing services that allow clients to look up the interfaces of installed EJB classes.

For more information, see Creating EJB Property Files.

Copy the Files to NAS
Copy the class files from your development machine to the destination server's APPS directory. You must preserve the directory structure used on the development machine.

Register the EJB
Once you have copied the files onto the destination machine, you must register the EJB using beanreg on the NAS host machine. BeanReg registers a bean locally using the .properties file that describes the bean. Registering your bean requires the deployment descriptor file you created in Creating a Deployment Descriptor.

For example, on Solaris machines, type the following at the command line;

% $GX_ROOTDIR/bin/beanreg filename.properties
On a Windows NT machine, type the following at the command line, using beanreg in %NASPATH%:

Z:\>beanreg filename.properties
Manually Deploying Servlets and JSPs To deploy a servlet or JSP manually, perform the following steps:

  1. Create servlet configuration files.
  2. Copy files to NAS.
  3. Register the servlet.
Create Servlet Configuration Files
You must create a configuration file for each servlet, and one for the application as a whole. These configuration files must be referenced in an application-wide configuration file called appInfo.ntv. Servlets that are not part of a specific application are part of the "generic" application, which also must have a configuration file appInfo.ntv.

Servlet configuration files can be named anything as long as the name contains the .ntv suffix and the filename is referenced in appInfo.ntv. They must be placed in a certain directory, which is specified in the next section, Copying the Files to NAS.

The following is an example of an appInfo.ntv file:

NTV-ASCII

{
"SessionInfo" NTV {
"timeout" Int "400",
"flags" StrArr ["SESSION DISTRIB"],
"sessionManagement" Int "0"
},
"ServletFiles" StrArr ["servInfo"],
"AppName" Str "nsOnlineBookstore",
}
AppName refers to the name of the application, which, in this case, is nsOnlineBookstore. servInfo refers to the servletInfo file, servInfo.ntv. You can find this file in the following location:

NAS install directory/APPS/NSOnlineBookstore/ntv
For more information, see Creating Configuration Files in the Programmer's Guide.

Copy the Files to NAS
Servlets and JSPs can be part of an application or exist outside of an application, depending upon how the web client invokes the servlet.

To copy these files to NAS, first follow the directions that apply to your application component:

Next, copy the class files into the NAS class path, which is usually $GX_ROOTDIR/APPS. You must preserve the directory structure when copying the class files. See the examples in Sample Directory Structures for All Servlets and JSPs and Sample Directory Structures for Servlets and JSPs in an Application for details.

Finally, copy static content like HTML and GIF files to the web server documentation root.

Copy Servlets as Part of an Application

For a servlet that's part of an application, the following URL would appear in the web client:

http://$HOSTNAME:$PORT/NASApp/$AppName/$ServletName
In this URL, $HOSTNAME is the DNS name of the host machine, $PORT is the TCP/IP port, NASApp is a key defined the registry to signal to NAS that the URL references a servlet, $AppName is the AppName variable in the appInfo.ntv files, and ServletName is the name of the servlet.

To mirror this URL on your own machine, copy the application's NTV files to the $GX_ROOTDIR/APPS/$AppName/ntv directory.

Note. The appInfo.ntv file must point to all relevant servletInfo.ntv files. If you change the names of the servletInfo.ntv files, you must reflect those changes in the appInfo.ntv file.

Copy JSPs as Part of an Application

For a JSP that's part of an application, copy the JSP into the $GX_ROOTDIR/APPS/$AppName directory, then refer to them using $AppName/jspname.jsp.

Copy Servlets Not Part of an Application

For a servlet that's not part of an application, the following URL would appear in the web client:

http://$HOSTNAME:$PORT/servlets/$ServletName
In this URL, $HOSTNAME is the DNS name of the host machine, $PORT is the TCP/IP port, servlets is a non-changable string, and ServletName is the name of the servlet.

To mirror this URL on your own machine, copy the servletInfo.ntv files to the $GX_ROOTDIR/APPS/ntv directory. You must update the appInfo.ntv file with the new servletInfo.ntv files.

Copy JSPs Not Part of an Application

For a JSP that's not part of an application, copy the JSP into the $GX_ROOTDIR/APPS/ directory, then refer to them using jspname.jsp.

Sample Directory Structures for Servlets and JSPs Not Part of an Application

For servlets and JSPs not in an application, use the following directory structures as examples:

NAS install directory (APPS is in the NAS class path):

/disk2/ns-home/nas/APPS/
Servlet with class name javaSpec:

/disk2/ns-home/nas/APPS/javaSpec.jsp
JSP referenced by javaSpec.jsp:

/disk2/ns-home/nas/APPS/javaSpec.jsp
Default NTV directory for all servlets and JSPs not in any application:

/disk2/ns-home/nas/APPS/ntv
Default appInfo.ntv file referencing all servlets not in an application:

/disk2/ns-home/nas/APPS/ntv/appInfo.ntv
Sample Directory Structures for Servlets and JSPs as Part of an Application

For servlets and JSPs in an application, use the following directory structures as examples. Here, the application name is Project 1.

NAS install directory (APPS is in the NAS class path):

/disk2/ns-home/nas/APPS/Project1/
Location of all NTV files for Project1:

/disk2/ns-home/nas/APPS/Project1/ntv/
Location of appInfo.ntv for Project1:

/disk2/ns-home/nas/APPS/Project1/ntv/appInfo.ntv
servletInfo.ntv file for Project1.webapp.NASservlet servlet which is referenced in the appInfo.ntv file for this project:

/disk2/ns-home/nas/APPS/Project1/ntv/NASservlet.ntv
NASservlet servlet with a full class name of Project1.webapp.NASservlet:

/disk2/ns-home/nas/APPS/Project1/webapp/NASservlet.class
NASservlet JSP file referencable with the name Project1/webapp/NASservlet.jsp:

/disk2/ns-home/nas/APPS/Poject1/webapp/NASservlet.jsp
URL to access NASservlet:

http://warp/NASApps/Project1/NASservlet
Register the Servlet
On the NAS host machine, run one of the following scripts on the appInfo.ntv file to register all servlets in the appInfo.ntv file:

On Solaris: servletReg.sh

On Windows NT: servletReg.bat

For example, on Solaris, you might type the following at the command line:

%$GX_ROOTDIR/bin/servletReg.sh -i appInfo.ntv
Manually Deploying Data Sources To deploy a data source manually, perform the following steps:

  1. Create the data source file.
  2. Register the data source.
Create the Data Source File
The data source file contains information necessary for accessing the database such as a user name and password. Using a text editor, create a data source file (filename.props) using the following example as a guide:

DataBase=ksample

DataSource=ksample
UserName=kdemo
PassWord=kdemo
ResourceMgr=rm_orcl #Optional
Data source files are not referenced at run time, so you need not place them in a specific directory on your NAS machine. However, it is good convention to place them in the APPS/$AppName directory.

For more information, see Creating Configuration Files.

Register the Data Source
After you have created the data source file, you must run dsreg on the NAS host machine.

For example, on Solaris machines, you might type the following at the command prompt:

$GX_ROOTDIR/bin/dsreg "jdbc/BookstoreDS" BookstoreDS.props
where jdbc/BookstoreDS is the data source name.

On Windows NT machines, you might type the following at the command prompt:

Z:\>dsreg "jdbc/BookstoreDS" BookstoreDS.props

Upgrading an Application
Frequently, application developers must upgrade an application that is already installed on an application server. Upgrading an application involves deploying updated application files to your Netscape Application Server (NAS) machine through the Deployment Manager, often to fix bugs or to add features to deployed applications. The application developer is ultimately responsible for this upgrade; however, you must work with the developer to prepare your NAS machine for the updated application files.

If you are upgrading an Enterprise Java Bean (EJB), you must prepare your NAS machine by stopping the server. You need not stop the server when upgrading JavaServer Pages (JSPs), servlets or AppLogics.

See the Programmer's Guide for specific information about application components and their requirements.

Dynamically Reloading Components You can reload servlets and JavaServer Pages (JSPs) into NAS without restarting the server. Simply re-deploy (and thus overwrite) the servlet or JSP. The next time it is required by the application, NAS automatically reloads that component. An exception to this is that if you change the session method in the application's configuration file, you must restart the web server as well as NAS.

Enterprise JavaBeans (EJBs) can not be dynamically reloaded. You must restart the server after reloading an EJB.

For more information about dynamic reloading, see Dynamic Loading in the Programmer's Guide.


Editing EJB Properties at Run Time
An Enterprise Java Bean (EJB) instance is created and managed by a container class, but some properties of an EJB can be customized at run time with the declarative properties editor. The declarative properties editor, which is a part of Netscape Application Server (NAS) Administrator, allows you to view read-only attributes of an EJB's deployment descriptor as well as edit application environment properties and the default session timeout value.

To launch the editor, perform the following steps:

  1. Click the Application button on the NAS Administrator toolbar to open the Application window.
  2. From the tree in the left pane of the window, select the EJB whose properties you want to edit.
  3. In the right pane of the Application window, click the Edit Deployment Descriptor button.
Editing General Attributes of an EJB Once you have launched the declarative properties editor, the General Attributes tab appears by default. Information about the EJB you selected in the left pane of the Application window appears, including the EJB's class names and type.

You can edit the selected EJB's session timeout in seconds by entering a value in the corresponding text box. This value indicates how long the EJB can exist without being accessed. When the timeout value is reached, the EJB is removed.

Editing EJB Access Control Click the Access Control tab to view and edit the access control lists that apply to the selected EJB and its methods. Access control lists specify security identities for a method or an entire EJB. These security identities are users or roles who are allowed to invoke the method.

The Allowed Identities field shows which users are currently able to access the selected bean. To modify Allowed Identities, perform the following steps:

  1. Click Choose Default Identities.
  2. Add or remove allowed identities from the list boxes using the arrow buttons.
  3. Click OK to dismiss the dialog box.
You can also modify access control at the method-level by applying an override to particular methods. For instance, if All Users have access to a DataAccess bean, you can limit the users who may access the create() method of that bean by setting a method override.

To add a method override, perform the following steps:

  1. Click the Add Method Override button.
  2. Select one or more methods.
  3. Click OK.
  4. Click a method to select it.
  5. Click the Edit Allowed Identities button.
  6. Add or remove Allowed Identities from the list boxes using the arrow buttons.
  7. Click OK.
Editing Environment Properties Click the Environment tab to add, edit and delete user-defined environment properties. Environment properties are elements specific to your application such as sales tax rates or zip codes. These properties are available when your EJB is running in a standard fashion. You can access an EJB's environment properties through the setEnvironment() method in javax.ejb.EJBContext.

To add a new environment property, perform the following steps:

  1. Click the Add New Property button.
  2. Type the name of the property in the Key field.
  3. Type the value of the property in the Value field.
  4. Click OK to dismiss the dialog box.
To delete or edit a property, highlight the property in the table on the Environment tab and click either the Delete Property or Edit Property button.

 

© Copyright 1999 Netscape Communications Corp.