BEA Home | Events | Solutions | Partners | Products | Services | Download | Developer Center | WebSUPPORT
| WebLogic Server Doc Home | Web Applications | Previous Topic | Next Topic | Contents | Index | View as PDF

Deploying Web Applications

The following sections describe how to deploy Web Applications:

- Overview of Deploying Web Applications

- Deploying Web Applications Using Auto-Deployment

- Deploying Web Applications with Production Mode Enabled

- Redeploying a Web Application with Production Mode Enabled

- Refreshing Static Components Without Redeploying the Application

- Un-deploying Web Applications

- Deleting a Web Application

- Deploying Stand-Alone Web Applications

Overview of Deploying Web Applications

Deploying a Web Application is the final step that allows WebLogic Server to serve the components of a Web Application to clients. You can deploy a Web Application using one of several procedures, depending on your environment and whether or not your Web Application is in production. You can use the WebLogic Server Administration Console, the weblogic.deploy utility, or you can use auto-deployment.

The instructions for deploying a Web Application presume that you have created a functional Web Application that uses the correct directory structure and contains the web.xml deployment descriptor and, if needed, the weblogic.xml deployment descriptor. For an overview of the steps required to create a Web Application, see Main Steps to Create a Web Application.

There are two modes you can use to run WebLogic Server, development mode and production mode. To enable development mode, start WebLogic Server with the following flag: -Dweblogic.ProductionModeEnabled=false (this is the default behavior). To enable production mode, start WebLogic Server with the following flag: -Dweblogic.ProductionModeEnabled=true. For information on setting these modes, see Starting and Stopping WebLogic Servers.

When you specify development mode, you can use the auto-deploy feature to quickly deploy a Web Application by copying it into the applications directory of your Administration Server, located in the config/mydomain directory of the WebLogic Server installation (where mydomain is the name of a WebLogic Server domain). WebLogic Server automatically deploys any application that is copied into the applications directory. If a Web Application in .war format is modified, WebLogic Server automatically redeploys the Web Application. If the Web Application is in exploded format, see Redeploying a Web Application in Exploded Directory Format. It is not advisable to store applications in the config/mydomain/applications directory. Applications already in this directory will deploy automatically even in production mode.

You can deploy a Web Application from your file system in exploded directory format or archived .war format. Exploded directory format means the Web Application components are arranged on your file system using the standard directory structure for Web Applications. A .war archive is created by using the Java jar utility to archive the contents of a Web Application in exploded directory format.

If you are using a cluster of managed WebLogic Servers, you can specify that your Web Application be deployed on one or more "targeted" Managed Servers. The Administration Server automatically copies the Web Application to the Managed Servers in the domain that have been targeted for the Web Application.

Deploying Web Applications Using Auto-Deployment

Auto deployment is a convenience feature designed for Web Application development and should not be used for production applications. When you move your application into production, use the manual deployment procedures described in Deploying Web Applications with Production Mode Enabled. You can only deploy a Web Application using auto-deployment on the Administration Server. If an auto-deployed Web Application is targeted to any Managed Servers, the Web Application is also deployed on the Managed Servers.

Before you can use auto-deployment, you must create a functional Web Application using the correct directory structure and containing the web.xml deployment descriptor and, if necessary, the weblogic.xml deployment descriptor. You can deploy your Web Application as an archived .war file or in exploded directory format (see Directory Structure).

How to Deploy a Web Application Using Auto-Deployment

To deploy a Web Application using auto-deployment:

1. Start your WebLogic Administration Server with the -DProductionModeEnabled=false flag. For more informations, see Starting and Stopping WebLogic Servers.

2. Copy the .war archive file or a directory containing your Web Application to the applications directory for your domain. The applications directory is located in the config/mydomain directory of the WebLogic Server installation (where mydomain is a WebLogic Server domain). The Web Application is automatically deployed by the Administration Server.

3. Configure the Web Application using the Administration Console.

   1. Start the Administration Console in a Web browser.

   2. Expand the Deployments node in the left pane.

   3. Expand the Web Applications node in the left pane. A list of Web Applications appears in the right pane, including the Web Application you just copied to the applications directory.

   4. Click on the name of the Web Application.

   5. Select the Targets tab and target servers, clusters, or virtual hosts by selecting the appropriate tab and moving a target from the Available to the Chosen column. An application is deployed to any Managed Servers when you target the Web Application to a server or cluster. Targeting a Web Application to a virtual host makes the Web Application available to clients through the virtual host.

   6. Click Apply.

   7. Configure other attributes under the Files and Other tabs. For more information, see Web Applications / Configuration.

   8. Click Apply.

4. Test your Web Application by accessing a resource through a Web browser. You access resources with a URL constructed as follows:

   >     http://myServer:myPort/myWebApp/resource

   Where:

   - myServer is the name of the machine hosting WebLogic Server

   - myPort is the port number where WebLogic Server is listening for requests

   - myWebApp is the name of the Web Application archive file (myWebApp.war, for instance) or the name of a directory containing the Web Application.

   - resource is the name of a resource such as a JSP, HTTP servlet, or HTML page.

Uploading a Web Application to the applications Directory

You can also use the Administration Console to upload a Web Application to the applications directory. This procedure can be useful if your WebLogic Server is located on a remote machine.

To upload a Web Application:

1. Start your WebLogic Administration Server with the -DProductionModeEnabled=false flag. For more informations, see Starting and Stopping WebLogic Servers.

2. Select the Web Applications node in the left pane.

3. Click Install a New Web Application.

4. Browse to the location in your file system of the .war file.

5. Click Upload. The Web Application is copied to the applications directory on the Administration Server and deployed.

Redeploying a Web Application Using Auto-Deployment

When you modify static components of a Web Application (such as a JSPs and HTML pages) that are deployed in the applications directory, and you are using auto-deployment, the Web Application must be redeployed in order for the changes to become effective. The procedure is different for Web Applications deployed as .war archive files and Web Applications deployed in exploded directory format.

Redeploying a Web Application in a .war Archive

Modifying the archive file automatically triggers redeployment of the Web Application. If an auto-deployed Web Application is targeted to any Managed Servers, the Web Application is also redeployed on the Managed Servers.

Redeploying a Web Application in Exploded Directory Format

You can redeploy a Web Application deployed in exploded directory format when using auto-deployment by modifying a special file called REDEPLOY, or you can use the Administration Console, or you can cause a partial redeploy by copying a new version of a class file over an old in the WEB-INF/classes directory.

Touching the REDEPLOY File

To re-deploy a Web Application by modifying the REDEPLOY file:

1. Create an empty file called REDEPLOY and place it in the WEB-INF directory of your Web Application. (You may have to create this directory.)

2. Modify the REDEPLOY file by opening it, modifying the contents (adding a space character is the easiest way to do this), and then saving the file. Alternately, on UNIX machines, you can use the touch command on the REDEPLOY file. For example:

   >     touch
   >     user_domains/mydomain/applications/DefaultWebApp/WEB-INF/REDEPL
   >     OY

   As soon as the REDEPLOY file is modified, the Web Application is redeployed.

Redeploying with the Administration Console

To redeploy a Web Application using the Administration Console:

1. Expand the Deployments node in the left pane.

2. Select the Web Application node.

3. Select the Web Application you want to redeploy.

4. Deselect the Deployed box in the right-hand pane.

5. Click Apply.

6. Check the Deployed box in the right-hand pane.

7. Click Apply.

Hot-Deployment

Redeploy files in the WEB-INF/classes directory in the following way. If a class is deployed in WEB-INF/classes, then simply copying a new version of the file with a later time stamp will cause the Web Application to reload everything in the WEB-INF/classes folder with a new classloader.

The frequency in which WLS will look at the filesystem is governed through the console. In the Deployments-->Web Applications tab, select your Web Application. Go to the Configuration tab, and Files subtab, and enter a value in seconds for the Reload Period.

Deploying Web Applications with Production Mode Enabled

To deploy a Web Application with Production Mode enabled, you must start WebLogic Admin Server with the -DProductionModeEnabled=true flag. WebLogic Admin Server can use this feature; managed servers cannot. For more information, see Starting and Stopping WebLogic Servers.

You can deploy a Web Application using either the Administration Console or the weblogic.deploy utility. When you deploy a Web Application it is automatically deployed to all of the targeted Managed Servers in the domain. (For more information on administering Managed Servers, see Configuring WebLogic Servers and Clusters.)

It is not advisable to store applications in the config/mydomain/applications directory. In production mode, WebLogic Server will not detect applications newly placed in the config/mydomain/applications directory, but applications that were detected in the directory before switching to production mode will continue to deploy automatically.

These deployment instructions presume that you have created a functional Web Application using the correct directory structure and containing the web.xml deployment descriptor and, if needed, the weblogic.xml deployment descriptor. You can deploy your Web Application as an archived .war file or in exploded directory format. For more information, see Directory Structure.

Deploying a Web Application Using the Administration Console

To deploy a Web Application using the Administration Console:

1. Start your WebLogic Server Administration Server.

2. Start the WebLogic Server Administration Console. For more information, see Overview of WebLogic Server Management

3. Expand the Deployments node in the left pane.

4. Right-click on the Web Applications node.

5. Select Configure a New WebAppComponent.

6. Enter the full path to the exploded directory or .war file in the Path URI field. For example:

   (exploded directory format) c:\myApps\myWebApp

   (archived format) c:\myApps\myWebApp.war

7. Click Create.

8. Select the new Web Application from the Web Applications node in the left pane.

9. Select the Targets tab in the right pane.

10. Select the Servers tab and move the appropriate servers to the Chosen box.

11. If you are using a cluster of WebLogic Servers, select the Clusters tab and move the appropriate clusters to the Chosen box.

12. If you are using virtual hosting, select the Virtual Hosts tab and target any virtual hosts that should apply to this Web Application. For more information, see Configuring Virtual Hosting.

13. Select the configuration tab and configure applicable attributes on the General, Files, and Other tabs. You can click on the question mark icons to get more information about these attributes.

14. Test your Web Application by accessing a resource through a Web browser. You access resources with a URL constructed as follows:

    >     http://myServer:myPort/myWebApp/resource

    Where:

    - myServer is the name of the machine hosting WebLogic Server

    - myPort is the port number where WebLogic Server is listening for requests

    - myWebApp is the name of the Web Application archive file (myWebApp.war, for instance) or the name of a directory containing the Web Application.

    - resource is the name of a resource such as a JSP, HTTP servlet, or HTML page.

Deploying a Web Application Using the weblogic.deploy Utility

To deploy a Web Application using the weblogic.deploy utility:

1. Set up your local environment so that WebLogic Server classes are in your system CLASSPATH and the JDK is available. You can use the setEnv script located in the config/mydomain directory to set the CLASSPATH.

2. Enter the following command:

   >     % java weblogic.deploy -port port_number -host host_name
   >        -component application:target deploy password application
   >     source

   Where:

   - host_name is the name of the machine hosting WebLogic Server

   - port_number is the port number where WebLogic Server is listening for requests

   - application is the name you want to assign to this Web Application.

   - target is the name of a server, cluster or virtual host to be targeted by this Web Application. You can enter multiple targets, separated by a comma.

   - password is your system administration password

   - source is the full pathname of the .war file you want to deploy, or the full pathname of a directory containing a Web Application in exploded directory format.

     For example:

     >     java weblogic.deploy -port 7001 -host myhost -component
     >     myWebApp:myserver deploy pswd1234 myWebApp d:\myWebApp.war

Redeploying a Web Application with Production Mode Enabled

To redeploy a Web Application with Production Mode enabled, you must start WebLogic Admin Server with the -DProductionModeEnabled=true flag. WebLogic Admin Server can use this feature; managed servers cannot. For more information, see Starting and Stopping WebLogic Servers.

When you modify a component (for instance, a servlet, JSP, or HTML page) of a Web Application on the Administration Server, you must take additional steps to refresh the modified component so that it is also deployed on any targeted Managed Servers. One way to refresh a component is to redeploy the entire Web Application. Redeploying the Web Application means that the entire Web Application (not just the modified component) is re-sent over the network to all of the Managed Servers targeted by that Web Application.

Note the following regarding redeployment of Web Applications:

- Depending on your environment, there may be performance implications due to increased network traffic when a Web Application is re-sent to the Managed Servers.

- If the Web Application is currently in production and in use, redeploying the Web Application causes WebLogic Server to lose all active HTTP sessions for current users of the Web Application.

- If you have updated any Java class files, you must redeploy the entire Web Application to refresh the class.

- If you change the deployment descriptors, you must redeploy the Web Application.

If you need to refresh static files such as JSPs, HTML files, image files, you can use the refresh option of the weblogic.deploy utility to refresh the static file. For more information, see Refreshing Static Components Without Redeploying the Application.

Redeploying a Web Application Using the Administration Console

To redeploy a Web Application throught the Administration Console:

1. Start the WebLogic Server Administration Console.

2. Expand the deployments node in the left pane.

3. Expand the Web Application node.

4. Select the Web Application you want to redeploy.

5. Deselect the Deployed box in the right-hand pane.

6. Click Apply.

7. Select the Deployed box in the right-hand pane.

8. Click Apply.

Note: When you redeploy a Web Application, any active HTTP sessions are lost.

Redeploying a Web Application Using the weblogic.deploy Utility

Enter the following command:

>     % java weblogic.deploy -port port_number -host host_name
>        update password application source

Where:

- host_name is the name of the machine hosting WebLogic Server.

- port_number is the port number where WebLogic Server is listening for requests.

- password is your system administration password.

- application is the name of the Web Application.

- source is the full pathname of the .war file you want to redeploy, or the full pathname of a directory containing a Web Application in exploded directory format.

Notes: When you redeploy a Web Application, any active HTTP sessions are lost.

Updating an application on any single server instance to which it is targeted causes it to be updated on all servers to which is targeted. For instance, if an application is targeted to a cluster, and you update it on one of the clustered servers instances, the application will be updated on all members of cluster. Similarly, if the application is targeted to a cluster and to a standalone server instance, updating it on the standalone server instance will result in its update on the cluster, and vice versa.

Partial Redeployment

Refreshing Static Components Without Redeploying the Application

To refresh static components of an application without having to redeploy the entire application, use the weblogic.refresh tool.

When you update a static file in a Web Application on the Administration Server, the file is not automatically copied to the Web Application on any Managed Servers, but you can use weblogic.refresh to refresh, add, or delete static files such as:

- JSPs

- XML files

- HTML files

- Image files, such as .gif and .jpg

- Text files

Refreshing JSPs does not require redeploying the Web Application because each JSP is loaded by its own classloader, of which the Web Application classloader is a parent.

Note the following limitations of this utility:

- You cannot use this utility to refresh Java class files.

- To use this utility, the Web Application must be deployed in exploded directory format, and if it is contained in an ear file, the ear file must be in exploded format. The utility does not work for components archived in .war files.

To refresh a static file:

1. Set up your development environment so that WebLogic Server classes are in your system CLASSPATH and the JDK is available. You can use the setEnv script located in the config/mydomain directory to set your environment.

2. Enter a command in the following form:

   >     % java weblogic.refresh -url -username -password -application
   >     -component -files -delete -root

   Where:

   - url is the URL of your WebLogic Administration Server.

   - username is the username for system administration.

   - password is your system administration password.

   - application is the name of an Enterprise Application that contains the Web Application being refreshed. If your Web Application is not part of an Enterprise Application, enter the name of the Web Application.

   - component is the name of the Web Application being refreshed.

   - files is a comma-separated list of files to be refreshed. The files can be specified using wildcards, e.g., *.jsp or *.gif. Note that to specify multiple files you cannot use both wildcards and multiple comma-separated files. Filenames must be relative filenames to the root of the Web Application, so if the file is ball.gif and is contained in a subdirectory \foo of the Web Application root directory, the filename is foo\ball.gif. If a file does not exist on the server, it will be created, along with any specified subdirectories.

   - if delete is set, named files will be deleted.

   - root is the directory from which files should be picked up for refresh. Default is the current directory.

     For example, the following command refreshes the files HelloWorld.jsp and foo\ball.gif in the myWebApp Web Application:

     >     java weblogic.refresh -url t3://localhost:7001 -username
     >     myUsername -password myPassword  -application myApplication
     >     -component myWebApp -root c:\stagedir\myWebApp
     >     HelloWorld.jsp,foo\ball.gif

Un-deploying Web Applications

Un-deploying a Web Application leaves your configuration intact, but makes the Web Application unavailable to respond to client requests. To un-deploy a Web Application you can use the Administration Console or the weblogic.deploy utility:

Un-deploying a Web Application Using the Administration Console

To un-deploy a Web Application using the Administration Console:

1. Start the Administration Console.

2. Expand the Deployments node in the left pane.

3. Expand the Web Applications node.

4. Select the Web Application you want to un-deploy.

5. Select the Configuration tab in the right pane.

6. Deselect the Deployed box.

7. Click Apply.

Un-deploying a Web Application Using the weblogic.deploy Utility

To un-deploy a Web Application using the weblogic.deploy utility:

1. Set up your development environment so that WebLogic Server classes are in your system CLASSPATH and the JDK is available. You can use the setEnv script located in the config/mydomain directory to set the CLASSPATH.

2. Enter the following command:

   >     % java weblogic.deploy -port port_number -host host_name
   >        undeploy password application source

   Where:

   - host_name is the name of the machine hosting WebLogic Server.

   - port_number is the port number where WebLogic Server is listening for requests.

   - password is your system administration password.

   - application is the name of the Web Application.

   - source is the full pathname of the .war file you want to redeploy, or the full pathname of a directory containing a Web Application in exploded directory format.

Deleting a Web Application

Deleting a Web Application removes all of the configuration information of your Web Application from your domain configuration and makes the Web Application unavailable to respond to client requests. You can delete a Web Application using the Administration Console or by using the weblogic.deploy utility.

Deleting a Web Application does not delete the Web Application from your file system.

Deleting a Web Application in the applications Directory

If you are running WebLogic Server in development mode (you started WebLogic Server with the -DProductionModeEnabled=false flag), to delete a Web Application in the applications directory, you must physically delete the directory or archive containing the Web Application from the applications directory.

Deleting a Web Application Using the Administration Console

To delete a Web Application using the Administration Console:

1. Start the WebLogic Server Administration Console. For more information, see Overview of WebLogic Server Management

2. Expand the Deployments node in the left pane.

3. Select the Web Applications node.

4. In the right pane, click the trash can icon next to the name of the Web Application you want to delete. You are prompted to confirm the deletion.

5. Click Yes.

Deleting a Web Application Using the weblogic.deploy Utility

To delete a Web Application using the weblogic.deploy utility:

1. Set up your development environment so that WebLogic Server classes are in your system CLASSPATH and the JDK is available. You can use the setEnv script located in the config/mydomain directory to set the CLASSPATH.

2. Enter the following command:

   >     % java weblogic.deploy -port port_number -host host_name
   >        delete password application

   Where:

   - host_name is the name of the machine hosting WebLogic Server

   - port_number is the port number where WebLogic Server is listening for requests.

   - password is your system administration password.

   - application is the name of the Web Application.

Deploying Stand-Alone Web Applications

If your Web Application is stand-alone, you can specify its context root in the weblogic.xml file using the context-root element. If the Web Application is part of an EAR, specify the context root in the EAR's application.xml file. A context-root setting in application.xml takes precedence over context-root setting in weblogic.xml. See context-root Element.

Copyright © 2001 BEA Systems, Inc. All rights reserved. Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.