Escolar Documentos
Profissional Documentos
Cultura Documentos
Server
Copyright
Copyright 2003 BEA Systems, Inc. All Rights Reserved.
Contents
iii
Exploded Archive Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 Unpacking an Archive File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 Location of Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8 Deployment Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8 WebLogic Server Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8 Clusters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 Virtual Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 Staging Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 Deployment Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12 Deployment Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12 Best Practices for Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Deployment Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Security Roles Required for Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
iv
Undeploying a Deployment Unit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10 Deploying Modules of an Enterprise Application to Different WebLogic Server Instances . 3-11 Deploying an Enterprise Application Using external_stage Mode . . . . . . . . . . . . . . . . . 3-13 Deploying an Enterprise Application with an Alternate (External) Application Descriptor. . 3-14 Deploying a Module Newly Added to an EAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14 Changing the Order of Deployment for a Deployment Unit . . . . . . . . . . . . . . . . . . . . . . 3-15 Changing a Server Staging Mode or Staging Directory . . . . . . . . . . . . . . . . . . . . . . . . . 3-15 Dynamically Updating Descriptors for a Deployment Unit . . . . . . . . . . . . . . . . . . . . . . 3-16 Redeploying Static Files in a Web Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17 Removing Files from a Web Application Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18 Managing Deployment Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
Ordering Startup Class Execution and Deployment . . . . . . . . . . . . . . . . . . . . . . . . . 4-8 Redeploying Applications and Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Limitations of Redeploying Applications and Modules . . . . . . . . . . . . . . . . . . . . . 4-10 Partial Redeployment for Exploded Web Applications . . . . . . . . . . . . . . . . . . . . . . 4-11 Deploying Enterprise Applications With Alternate Deployment Descriptors . . . . . . . . 4-11 Common Uses for Alternate Deployment Descriptors . . . . . . . . . . . . . . . . . . . . . . 4-12 Limitations of Alternate Deployment Descriptors. . . . . . . . . . . . . . . . . . . . . . . . . . 4-12 Command-Line Options for Specifying Descriptors . . . . . . . . . . . . . . . . . . . . . . . . 4-13 Deployment Topics for Developers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13 Auto-Deployment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13 Enabling and Disabling Auto-Deployment. . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14 Auto-Deploying, Redeploying, and Undeploying Archived Applications. . . . 4-14 Auto-Deploying, Redeploying, and Undeploying Applications in Exploded Archive Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14 Application Lifecycle Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16 Registering Events in weblogic-application.xml . . . . . . . . . . . . . . . . . . . . . . . 4-16 Basic Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17 Configuring Lifecycle Events: URI Parameter. . . . . . . . . . . . . . . . . . . . . . . . . 4-19 Application Lifecycle Event Behavior During Re-deployment . . . . . . . . . . . . 4-21
vi
vii
viii
This document describes how to deploy and redeploy applications and standalone modules on WebLogic Server in a production environment. The document is organized as follows: Chapter 1, Overview of WebLogic Server Deployment, provides an overview of the types of deployment units you can deploy to WebLogic Server. Chapter 2, Quickstart Guide to Deployment, describes how to quickly deploy a new application or standalone module to WebLogic Server. Chapter 4, Advanced Deployment Topics, provides detailed information about how WebLogic Server deploys and redeploys application modules. Chapter 3, Performing Common Deployment Tasks, describes how to perform different deployment tasks using both the Administration Console and the weblogic.Deployer command-line utility. Chapter 5, Deployment Tools Reference, provides a complete reference to the weblogic.Deployer command-line utility and describes other tools used to deploy application modules.
Audience
This document is written mainly for Administrators who want to deploy Java 2 Platform, Enterprise Edition (J2EE) applications or application modules to WebLogic Server. This document assumes that you are working in a production environment, which is generally
ix
characterized by multiple WebLogic Server instances or clusters running on multiple machines. It also assumes that you have one or more application module archive files that have been tested and are ready to deploy on a production server. If you are an engineer and need to deploy or package applications in a development environment, see Developing WebLogic Server Applications.
Contact Us!
Your feedback on BEA documentation is important to us. Send us e-mail at docsupport@bea.com if you have questions or comments. Your comments will be reviewed directly by the BEA professionals who create and update the documentation. In your e-mail message, please indicate the software name and version you are using, as well as the title and document date of your documentation. If you have any questions about this version of BEA WebLogic Server, or if you have problems installing and running BEA WebLogic Server, contact BEA Customer Support through BEA WebSupport at http://www.bea.com. You can also contact Customer Support by using the contact information provided on the Customer Support Card, which is included in the product package. When contacting Customer Support, be prepared to provide the following information: Your name, e-mail address, phone number, and fax number
x Deploying WebLogic Server Applications
Your company name and company address Your machine type and authorization codes The name and version of the product you are using A description of the problem and the content of pertinent error messages
Documentation Conventions
The following documentation conventions are used throughout this document. Convention
Ctrl+Tab italics
monospace text
Usage
Keys you press simultaneously. Emphasis and book titles. Code samples, commands and their options, Java classes, data types, directories, and file names and their extensions. Monospace text also indicates text that the user is told to enter from the keyboard. Examples: import java.util.Enumeration; chmod u+w * config/examples/applications .java config.xml float
Placeholders. Example: String CustomerName; Device names, environment variables, and logical operators. Examples:
LPT1 BEA_HOME OR
{ }
xi
Convention
[ ]
Usage
Optional items in a syntax line. Example:
java utils.MulticastTest -n name -a address [-p portnumber] [-t timeout] [-s send]
...
Indicates one of the following in a command line: An argument can be repeated several times in the command line. The statement omits additional optional arguments. You can enter additional parameters, values, or other information
. . .
Indicates the omission of items from a code example or from a syntax line.
xii
CHAPTER
The following sections provide a basic overview of key BEA WebLogic Server deployment topics: Deployment Units on page 1-2 Deployment Files on page 1-6 Deployment Targets on page 1-8 Staging Modes on page 1-9 Deployment Names on page 1-12 Deployment Tools on page 1-12 Security Roles Required for Deployment on page 1-14
1-1
If you are an engineer and need to deploy or package applications in a development environment, see Developing WebLogic Server Applications. Also see Deployment Topics for Developers on page 4-13 for information about deployment features that apply to development environments.
Deployment Units
A deployment unit refers to a J2EE application (an Enterprise Application or Web Application) or a standalone J2EE module (an EJB or Resource Adapter) that has been organized according to the J2EE specification and can be deployed to WebLogic Server. For each type of deployment unit, the J2EE specification defines both the required files and their location in the directory structure of the application or module. Deployment units may include Java classes for EJBs and servlets, resource adapters, Web pages and supporting files, XML-formatted deployment descriptors, and even other modules. J2EE does not specify how a deployment unit is deployed on the target serveronly how standard applications and modules are organized. WebLogic Server supports deployments that are packaged either as archive files using the jar utility, or as exploded archive directories.
Standalone Modules
J2EE provides specifications for creating standalone modules, which include Enterprise JavaBeans and resource adapter modules. WebLogic Server also supports deploying Web Services modules, which are not part of the J2EE specification. Standalone modules generally provide parts of a larger, distributed application, but do not necessarily provide a direct user interface. For more information on a particular module type, refer to the J2EE 1.3 specification at: http://java.sun.com/j2ee/download.html#platformspec.
Enterprise JavaBean
Enterprise JavaBeans (EJBs) are reusable Java components that implement business logic and enable you to develop component-based distributed business applications. EJB modules are packaged as archive files having a .jar extension, but are generally deployed as exploded archive directories. The archive file or exploded archive directory for an EJB contains the compiled EJB classes, optional generated classes, and XML deployment descriptors for the EJB. See Programming WebLogic Server Enterprise JavaBeans for more information on the different types of EJBs.
1-2
Deployment Units
Resource Adapter
A Resource Adapter (also referred to as a connector) adds Enterprise Information System (EIS) integration to the J2EE platform. Connectors provide a system-level software driver that WebLogic Server can use to connect to an EIS. Connectors contain both the Java classes, and if necessary, the native components required to interact with the EIS. See Programming WebLogic Server J2EE Connectors for more information. Note: Resource Adapters cannot be deployed as exploded archive directories.
Web Services
Web Services are a type of service that can be shared by and used as components of distributed Web-based applications. They commonly interface with existing back-end applications, such as customer relationship management systems, order-processing systems, and so on. A Web Service module is a virtual module that includes both a Web Application and a Web Service deployment descriptor at minimum. A Web Service module may also include EJBs that implement the Web Service. See Programming WebLogic Web Services for more information.
Deployable Applications
J2EE also defines several different types of deployable applications: Web Applications, Enterprise Applications, and client applications. Applications generally include one or more standalone J2EE modules to provide a logical service, and may also provide a direct user interface to the applications contents.
Web Application
A Web Application always includes the following files: A servlet or JSP page, along with any helper classes. A web.xml deployment descriptor, a J2EE standard XML document that configures the contents of a WAR file. Web Applications may also contain JSP tag libraries, static .html and image files, supporting classes and .jar files, and a weblogic.xml deployment descriptor, which configures WebLogic Server-specific elements for Web Applications. See Developing Web Applications for WebLogic Server for more information.
1-3
Enterprise Application
An Enterprise Application consists of one or more of the following J2EE applications or modules: Web Applications Enterprise Java Beans (EJB) modules Resource Adapter modules An Enterprise Application is packaged as a JAR file with an .ear extension, but is generally deployed as an exploded EAR directory. An exploded EAR directory contains all of the JAR, WAR, and RAR modules (also in exploded format) for an application as well as the XML descriptor files for the Enterprise Application and its bundled applications and modules. See Developing WebLogic Server Applications for more information.
1-4
Deployment Units
the new behavior is read from the descriptor file and implemented when you deploy the application or module. For example, the WebLogic deployment descriptors for an EJB allow you to specify the number of beans to keep in the cache when you deploy the EJB to a server. If you need to change the number of cached beans for performance reasons, you simply change the deployment descriptor. J2EE defines the organization and content of required XML deployment descriptors for each deployment unit. In addition, you can specify optional WebLogic Server XML deployment descriptors to configure WebLogic-specific behavior for handling the deployment. WebLogic Server deployment descriptors enable you to maintain the portability of the original J2EE module while utilizing features only available in WebLogic Server. Table 1-1 lists the types of deployment units and their associated J2EE-standard and WebLogic-specific deployment descriptors. Table 1-1 J2EE and WebLogic Deployment Descriptors Deployment Unit
Web Application
Scope
J2EE WebLogic
Deployment Descriptors
WEB-INF/web.xml WEB-INF/weblogic.xml META-INF/ejb-jar.xml META-INF/weblogic-ejb-jar.xml META-INF/weblogic-cmp-rdbms-jar.xml META-INF/ra.xml META-INF/weblogic-ra.xml
Enterprise Bean
J2EE WebLogic
Connector
J2EE WebLogic
Web Service
J2EE
Web Services have no J2EE descriptor. However, a Web Service module is typically packaged as an Enterprise Application that contains both a Web Application and EJB modules. For this reason, Web Services modules generally require J2EE descriptors required for those modules.
WEB-INF/web-services.xml META-INF/application.xml META-INF/weblogic-application.xml
1-5
Scope
J2EE WebLogic
Deployment Descriptors
META-INF/application-client.xml client-application.runtime.xml
You create deployment descriptors manually, or generate them with WebLogic Server Java-based utilities. When you receive a J2EE-compliant JAR file from a developer, it should already contain the J2EE-defined and WebLogic Server deployment descriptors. The Administration Console also enables you to modify key deployment descriptor elements of a deployed application, which can help you tune the applications run-time behavior and performance.
Deployment Files
WebLogic Server allows you to store deployment units either as a single archive file, or as an exploded directory that contains the same contents of the archive file.
Archive Files
In most production environments, you receive a deployment unit as an archive file. An archive file is a single file that contains all of an applications or modules classes, static files, directories, and deployment descriptor files. Archive files are typically created by using the jar utility or Ants jar tool. Deployment units that are packaged using the jar utility have a specific file extension depending on the type: EJBs are packaged as .jar files. Web Applications are packaged as .war files. Resource Adapters are packaged as .rar files. Enterprise Applications are packaged as .ear files, and can contain any combination of EJBs, Web Applications, and Resource Adapters. Web Services can be packaged either as .ear files or as .war files. Note: Startup and shutdown classes are not packagedyou simply specify the classpath to use when assigning target servers.
1-6 Deploying WebLogic Server Applications
Deployment Files
Although you can deploy an archive file directly to WebLogic Server, deploying Exploded Archive Directories provides some additional redeployment capabilities.
If you are unpacking an archive file that contains other module archive files (for example, an Enterprise Application or Web Service that includes JAR or WAR files) and you want to perform
Deploying WebLogic Server Applications 1-7
partial updates of those modules, you must expand the embedded archive files as well. Make sure that you unpack each module into a subdirectory having the same name as the archive file. For example, unpack a module named myejb.jar into a /myejb.jar subdirectory of the exploded Enterprise Application directory. Note: If you want to use different subdirectory names for the archived modules in an exploded EAR file, you must modify any references to those modules in the application itself. For example, you must update the URI values specified in application.xml and CLASSPATH entries in the manifest.mf file.
Location of Files
To deploy a new archive or exploded archive directory, the file(s) must be accessible by the Administration Server for your domain. This means they must reside on the Administration Server machine, or they must be available via a remote, network-mounted directory. When using the Administration Console to deploy a module for the first time, you have the option to upload files to the Administration Server machine if they are not otherwise available. Files are uploaded to the location specified by the Upload Directory Name attribute.
Deployment Targets
Deployment targets are the servers to which you deploy an application or standalone module. Valid deployment targets include WebLogic Server instances, clusters, and virtual hosts. During the deployment process, you select the list of targets from the available servers, clusters, and virtual hosts configured in your domain. You can also change the target list at any time after you have deployed a module. The following sections describe target types in more detail.
1-8
St ag ing M od es
Clusters
If you are deploying to a cluster of WebLogic Server instances, by default the deployment targets all server instances in the cluster. This corresponds to homogenous module deployment, which is recommended in most clusters. If you want to deploy a module only to a single server in the cluster (that is, pin a module to a servers), you can also select the individual server name. This type of deployment is less common, and should be used only in special circumstances where pinned services are required. See Understanding Cluster Configuration and Application Deployment for more information. Note: Pinning a deployment to a subset of server instances in a cluster (rather than a single server) is not recommended and will generate a warning message.
Virtual Hosts
Virtual hosting allows you to define host names to which servers or clusters respond. When you use virtual hosting, you use DNS naming to specify one or more host names that map to the IP address of a WebLogic Server or cluster, and you specify which applications are served by each virtual host. You select a configured virtual host name as you would a WebLogic Server instance or cluster name during deployment. See Configuring Virtual Hosting in Configuring and Managing WebLogic Server for more information. Note: If the context root for a Web Application is blank in weblogic.xml file and the virtual host is targetted to a server instance, the Web Application should be deployed only to the Virtual Host or to the server instance.
Staging Modes
The deployment staging mode determines how deployment files are made available to target servers that must deploy an application or standalone module. WebLogic Server provides three different options for staging files: stage mode, nostage mode, and external_stage mode. The following table describes the behavior and best practices for using the different deployment staging modes.
1-9
Behavior
The Administration Server first copies the deployment unit source files to the staging directories of target servers specified by the Staging Directory Name attribute. The target servers then deploy using their local copy of the deployment files.
When to Use
Deploying small or moderate-sized applications to multiple WebLogic Server instances. Deploying small or moderate-sized applications to a cluster.
1-10
St ag ing M od es
Behavior
The Administration Server does not copy deployment unit files. Instead, all servers deploy using the same physical copy of the deployment files, which must be directly accessible by the Administration Server and target servers. With nostage deployments of exploded archive directories, WebLogic Server automatically detects changes to a deployments JSPs or Servlets and refreshes the deployment. (This behavior can be disabled if necessary.)
When to Use
Deploying to a single-server domain. Deploying to a cluster on a multi-homed machine. Deploying very large applications to multiple targets or to a cluster where deployment files are available on a shared directory. Deploying exploded archive directories that you want to periodically redeploy after changing content. Deployments that require dynamic update of selected Deployment Descriptors via the Administration Console. Deployments where you want to manually control the distribution of deployment files to target servers. Deploying to domains where third-party applications or scripts manage the copying of deployment files to the correct staging directories. Deployments that do not require dynamic update of selected Deployment Descriptors via the Administration Console (not supported in external_stage mode). Deployments that do not require partial redeployment of application components.
external_stage
The Administration Server does not copy deployment files. Instead, the Administrator must ensure that deployment files are distributed to the correct staging directory location before deployment (for example, by manually copying files prior to deployment). With external_stage deployments, the Administration Server requires a copy of the deployment files for validation purposes. Copies of the deployment files that reside in target servers staging directories are not validated before deployment.
Most deployments use either stage or nostage modes, and the Administration Console automatically suggests the appropriate mode when you deploy an application or module. For
Deploying WebLogic Server Applications 1-11
more information about staging modes, see Deployment Staging Modes and Staging Directories in Advanced Deployment Topics on page 4-1.
Deployment Names
When you first deploy an application or standalone module to one or more WebLogic Server instances, you specify a deployment name to describe collectively the deployment files, target servers, and other configuration options you selected. You can later redeploy or stop the deployment unit on all target servers by simply using the deployment name. The deployment name saves you the trouble of re-identifying the deployment files and target servers when you want to work with the deployment unit across servers in a domain. If you do not specify a deployment name at deployment time, the deployment tool selects a default name. For exploded archive directories, the default deployment name is the name of the top-level directory you deploy. For archive files, the deployment name is the name of the archive file without the file extension (myear for the file myear.ear).
Deployment Tools
WebLogic Server provides several tools for deploying applications and standalone modules: Administration Consoleprovides a series of web-based Deployment Assistants that guide you through the deployment process. The Administration Console also provides controls for changing and monitoring the deployment status, and changing selected deployment descriptor values while the deployment unit is up and running. Use the Administration Console when you need to perform basic deployment functions interactively and you have access to a supported browser.
weblogic.Deployerprovides a command-line based interface for performing both basic and advanced deployment tasks.
Use weblogic.Deployer when you do not have access to a browser or graphical user interface environment, and you want to perform deployment tasks. You can also use weblogic.Deployer when you want to automate deployment tasks through shell scripts or batch processes, rather than through Ant tasks.
wldeploy is an Ant task version of the weblogic.Deployer utility. You can automate deployment tasks by placing wldeploy commands in an Ant build.xml file and running Ant to execute the commands.
The deployment API allows you to perform deployment tasks programmatically using Java classes.
1-12 Deploying WebLogic Server Applications
The applications directory of a server allows you to deploy an application quickly for evaluation or testing in a development environment.
Deployment Operations
The deployment tools provide support for performing these common deployment operations: Deploymaking deployment source files available to target servers and loading classes into classloaders so that applications are available to clients. Distributefor stage mode deployments, only copy the deployment files to the target servers (but do not start the deployment).
Deploying WebLogic Server Applications 1-13
Redeployupdating an deployment unit or part of a deployment unit (for example, an EAR, a module within an EAR, or a static file in a Web Application) that is currently deployed and available to clients. When redeploying an entire application, all of the applications modules must redeploy successfully or the entire application is stopped. Note: An application becomes unavailable to clients during redeployment. WebLogic Server doesn't guarantee the operation of the application and deployment task if there is an access from the client at this time. For this reason, redeployment is not recommended for use in a production environment. Stopunloading an applications classes and making an application unavailable to clients. Stopping still leaves the deployment files and deployment name available to target servers for subsequent redeployment or starting. Startreloading an applications classes into classloaders and making the application available to clients. Starting requires that the deployment files be available on target servers as a result of an earlier deployment. Undeploystopping a deployment unit and then removing its deployment files and deployment name from target servers. Note: An application becomes unavailable to clients during undeployment. WebLogic Server doesn't guarantee the operation of the application and deployment task if there is an access from the client at this time.
1-14
CHAPTER
The following sections explain how to deploy an application or standalone module quickly in a BEA WebLogic Server domain: Step 1: Unpack the Archive File (if Necessary) on page 2-1 Step 2: Start the Deployment Assistant on page 2-2 Step 3: Upload Deployment Files (if Necessary) on page 2-2 Step 4: Select the Deployment Files on page 2-3 Step 5: Select the Target Servers on page 2-3 Step 6: Deploy the Files on page 2-4
2-1
If you are unpacking an EAR archive, the archive may contain additional archive files (.jar and .war extensions). In this case, also unpack the embedded archives in the exploded directory. Make sure the module subdirectories have the same name as the archive files, or you will need to update references to those modules elsewhere in the application. See Exploded Archive Directories on page 1-7.
2-2
2-3
2-4
CHAPTER
The following sections describes how to perform common deployment tasks using the Administration Console and weblogic.Deployer utility: Uploading Deployment Files to the Administration Server on page 3-2 Deploying an Application or Standalone Module to Servers on the Same Machine on page 3-3 Deploying an Application or Standalone Module to Servers on Multiple Machines on page 3-5 Changing the Target List for an Existing Deployment on page 3-7 Redeploying or Stopping a Deployment Unit on page 3-8 Undeploying a Deployment Unit on page 3-10 The following sections describe advanced deployment tasks: Deploying Modules of an Enterprise Application to Different WebLogic Server Instances on page 3-11 Deploying an Enterprise Application Using external_stage Mode on page 3-13 Deploying an Enterprise Application with an Alternate (External) Application Descriptor on page 3-14 Deploying a Module Newly Added to an EAR on page 3-14 Changing the Order of Deployment for a Deployment Unit on page 3-15
3-1
Changing a Server Staging Mode or Staging Directory on page 3-15 Dynamically Updating Descriptors for a Deployment Unit on page 3-16 Redeploying Static Files in a Web Application on page 3-17 Removing Files from a Web Application Deployment on page 3-18 Managing Deployment Tasks on page 3-18
Startup & ShutdownStartup classes and shutdown classes 4. In the right pane, select the Deploy a new deployment unit link, where deployment unit is the type of application or standalone module you want to deploy. This initiates the Deployment Assistant for the deployment unit. 5. The right pane provides a link to upload the deployment files. Click the link to display the upload page. 6. Use the Browse button to locate the archive file on the local file system that you want to upload to the Administration Server. Select the file and click Open. (You cannot select an exploded archive directory using the Administration Console.) 7. Click the Upload tab to copy the selected file to the Administration Servers upload directory specified by the Upload Directory Name attribute.The Administration Console automatically opens the upload directory so that you can select the uploaded file for deployment. 8. Continue deploying using the uploaded archive file.
Weblogic.Deployer Tasks
When using weblogic.Deployer to deploy a new application or standalone module, add the -upload option to upload the deployment files. For example:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name myapp -targets myserver -upload -deploy c:\localfiles\myapp.ear weblogic.Deployer copies the deployment files to the Administration Servers upload directory specified by the Upload Directory Name attribute. The target servers then deploy using their local copy of the deployment files. To upload an exploded archive directory, specify the directory name instead of an archive filename (for example c:\localfiles\myappEar).
3-3
Note: Nostage mode is the default when you deploy an application or standalone module to the Administration Server; you do not need to specify nostage mode in this case.
3-4
I will make the application accessible from the following location This option corresponds to nostage mode, where all targets deploy the files from the specified location. 8. Click Deploy to deploy the files.
Weblogic.Deployer Tasks
When using the weblogic.Deployertool utility, specify the nostage mode explicitly when you deploy to servers on the same machine. For example:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mydeploymentname -targets myserver1,myserver2,myserver3 -nostage -deploy c:\localfiles\myapp.ear
3-5
2. Expand the Deployments node in the left pane to display the different deployment units. 3. In the left pane, select the type of deployment unit that you want to deploy. The available deployment units are: ApplicationsEnterprise Applications or Web Services packaged as .ear files or directories EJB ModulesEnterprise JavaBeans packaged as .jar files or directories Web Application ModulesWeb Applications or Web Services packaged as .war files or directories Connector ModulesResource Adapters packaged as .jar files or directories Startup & ShutdownStartup classes and shutdown classes 4. In the right pane, select the Deploy a new deployment unit link, where deployment unit is the type of application or standalone module you want to deploy. This initiates the Deployment Assistant for the deployment unit. 5. In the first step of the Deployment Assistant, select the archive file or exploded archive directory that you want to deploy. See Deploying Applications and Modules in the Administration Console Online Help if you need further instructions about using the Deployment Assistants. 6. In the second step of the Deployment Assistant, select the servers and cluster to which you want to deploy the application. 7. In the third step of the Deployment Assistant, review your choices and specify a deployment name. In the Source Accessibility header, make sure that the following option is selected: Copy this application onto every target for me This option corresponds to stage mode, where the Administration Server copies the deployment files to each target server before the servers deploy the application or module. 8. Click Deploy to deploy the files.
Weblogic.Deployer Tasks
When deploying to multiple machines using the weblogic.Deployer utility, specify the nostage or external_stage mode explicitly at the command line. The deployment uses stage mode by default if no mode is specified. For example:
3-6
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mydeploymentname -targets myserver1,myserver2,myserver3 -stage -deploy c:\localfiles\myapp.ear
3-7
5. Click the Targets tab in the right pane to show the current target servers for the deployment. If you selected an Enterprise Application, the pane displays a target list for each module that makes up the application. 6. Use the checkboxes next to each server name to add or remove servers from the target list. Click Apply to apply your changes. 7. Select the Deploy tab in the right pane. 8. Click Deploy this Application; the Administration Console deploys the application on newly-added servers, and redeploys the application on existing target servers.
Weblogic.Deployer Tasks
Note: You cannot use weblogic.Deployer to remove a server from a deployment units target list if the application or module is already deployed. To add a new server to the target list using weblogic.Deployer, simply specify the new list of target servers with the deploy command. For example:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mydeploymentname -deploy -targets server1, newserver
3-8
Weblogic.Deployer Tasks
To redeploy a deployment unit using the weblogic.Deployer utility, use the redeploy command and specify the deployment name. Specifying only the deployment name redeploys an application on all existing target server instances, as in:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name myenterpriseapp -redeploy
Note: For applications deployed in a cluster, redeployment occurs on all target server instances in the cluster. If the application was previously deployed to all servers in the cluster, you cannot subsequently redeploy the application on a subset of servers in the cluster. If an application was previously deployed to multiple, non-clustered server instances, you can specify a target list to redeploy the application on a subset of the target servers, as in:
Deploying WebLogic Server Applications 3-9
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mydeploymentname -redeploy -targets myserver1,myserver2
The weblogic.Deployer utility uses a different command form if you want to redeploy individual modules of a deployed Enterprise Application. To redeploy a subset of the modules of an Enterprise Application, specify modulename@servername in the target server list. For example:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name myenterpriseapp -redeploy -targets mymodule1@myserver1,mymodule2@myserver2
Note: If the application was previously deployed to a cluster, you must redeploy the module to the entire cluster, rather than a subset of servers. If you specify a subset of servers in the cluster, weblogic.Deployer responds with the error:
An attempt to add server target target_name to module module_name has been rejected . This is because its parent cluster, cluster_name, is aso targeted by the module.
3-10
Dep loyin g Mod ul es o f an En t erp r ise Ap pli cat io n t o Di ff er en t Web Log ic Ser ve r Ins ta nc es
Weblogic.Deployer Tasks
To undeploy a deployment unit from the domain using weblogic.Deployer, specify the undeploy option. For example:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mymodule -undeploy
3-11
5. In the first step of the Deployment Assistant, select the EAR file or exploded Enterprise Application directory that you want to deploy. See Deploying Applications and Modules in the Administration Console Online Help if you need further instructions about using the Deployment Assistants. After you have selected the deployment files, click the Target Each Module button to begin targeting the individual JAR and WAR modules included in the Enterprise Application. 6. In the second page of the Deployment Assistant, select the servers and clusters to which you want to deploy the current module. Note that your selection of target servers applies only to the module name displayed at the top of the page. Click Continue to select target servers for the next module in the Enterprise Application. 7. Repeat step 6 for each module included in the Enterprise Application. When you have finished targeting all available modules, continue with the next step. 8. After you have finished targeting each module, you can review your choices. The Deployment Targets section of the page displays each module in the Enterprise Application and its associated targets. If you need to change the target servers for one or more modules, click your browsers back button and reselect the targets. 9. Select one of the following options in the Source accessibility section to set the deployment staging mode for the application: Copy this application onto every target for meThis option corresponds to stage mode, where the Administration Server copies the deployment files to each target server before the servers deploy the application. I will make the application accessible from the following locationThis option corresponds to nostage mode, where all targets deploy the files from the specified location. 10. Accept the default name for the Enterprise Application, or enter a new name to use to refer to this application in the Administration Console. 11. Click Deploy to deploy all modules.
Weblogic.Deployer Tasks
When deploying modules to different Weblogic Server instances using the weblogic.Deployer utility, specify individual modules using the module_name@target_name syntax. For example:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name myenterpriseapp
3-12
When you specify Web Application modules that are part of an .ear file, you must use the Web Applications context root name as the module name. For example, if the application.xml file for a file, myapp.ear, defines:
<module> <web> <web-uri>myweb.war</web-uri> <context-root>/welcome</context-root> </web> </module>
you could deploy only the Web Application by using a command similar to:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mywebapplication -targets welcome@myserver1 -stage -deploy c:\localfiles\myapp.ear
3-13
java weblogic.Deployer -adminurl http://localhost:7001 -name weblogic -password weblogic -external_stage -name myEARExternal -deploy c:\myapps\myear
weblogic.Deployer Tasks
To specify an external application.xml and weblogic-application.xml file when deploying an Enterprise Application, use the command:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name myapplication -targets myserver1,myserver2,myserver3 -stage -deploy -altappdd c:\myfiles\myextapplication.xml -altwlsappdd c:\myfiles\myextwlsapplication.xml c:\localfiles\myapp.ear
Note: This command deploys the new module without redeploying the other modules in the application. You must specify the correct file extension (.war in the above example) for archived modules in an EAR file.
3-14
Modules deployed in versions of WebLogic Server prior to 7.0 specify the load order value in their deployment descriptor files; you cannot change this load order using the Administration Console.
Notes: You can only change the server staging mode by using the Administration Console or by directly changing the ServerMBean via JMX. Changing the server staging mode does not affect existing applications. If you want to change the staging mode for an existing application, you must undeploy the application deployment and then redeploy it with the new staging mode.
3-16
1. Deploy the Enterprise Application as an exploded archive directory. If the application contains multiple EJB, Web Application, or Resource Adapter modules, make sure that those modules also reside as exploded directories having the correct subdirectory names. (Module subdirectories must match the URI values specified in the Enterprise Applications application.xml descriptor). 2. In the Administration Console, expand the Deployments node in the left pane. 3. Expand the node in the left pane that corresponds to the deployed Enterprise Application. This displays all of the modules contained in the enterprise application. 4. In the left pane, select the name of the EJB, Web Application, or Resource Adapter module whose descriptors you want to edit. 5. In the right pane, select the Configuration->Descriptor tab. 6. Use the Configuration->Descriptor tab to make available changes to the modules deployment descriptors, and click Apply. Your changes are automatically persisted to the modules XML deployment descriptor file, and the changes are reflected in all WebLogic Server instances that host the deployed module.
weblogic.Deployer Tasks
To redeploy a single file associated within a deployment unit, specify the file name at the end of the redeploy command. For example:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mywebapp -redeploy mywebapp/copyright.html
Always specify the pathname to updated files relative to the root directory of the exploded archive directory. In the above example, the Web Application is deployed as part of an Enterprise Application, so the module directory is specified (mywebapp/copyright.html). If the Web Application module had been deployed standalone, rather than as part of an Enterprise Application, the file would have been specified alone (copyright.html).
3-17
You can also redeploy an entire directory of files by specifying a directory name instead of a single file:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mywebapp -redeploy mywebapp/myjsps
In the above example, all files and subdirectories located in the myjsps subdirectory of the Enterprise Application are redeployed. Note: The refresh tools are deprecated and will be removed in a future WebLogic Server release. Use weblogic.Deployer instead.
Always specify the pathname to updated files relative by starting at the top level of the exploded archive directory. In the above example, the Web Application resides in an exploded archive directory named mywebapp.
3-18
Ma na gi ng Depl oymen t T as ks
weblogic.Deployer Tasks
The weblogic.Deployer utility enables you to monitor and cancel running deployment tasks. weblogic.Deployer also enables you to assign your own task identification numbers for use with subsequent commands. The following command assigns task ID 73 to a new deployment action:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mymodule -targets myserver -id redeployPatch2 -nowait -deploy c:\localfiles\myapp.ear
You can later check the status of the task using the following command:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -id redeployPatch2 -list
You can later check the status of running tasks using the following command:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -listtask
If a task takes too long to complete you can cancel it using the command:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -id redeployPatch2 -cancel
3-19
3-20
CHAPTER
The following sections describe more advanced deployment topics that might not be used in every WebLogic Server installation: Two-Phase Deployment Protocol on page 4-1 WebLogic Server 6.x Deployment Protocol (Deprecated) on page 4-3 Enforcing Cluster Constraints with Two-Phase Deployment on page 4-4 Deployment Staging Modes and Staging Directories on page 4-5 Deployment Order on page 4-7 Redeploying Applications and Modules on page 4-9 Deploying Enterprise Applications With Alternate Deployment Descriptors on page 4-11 Deployment Topics for Developers on page 4-13
4-1
Phase 1: Prepare
The prepare phase ensures that the application and its modules are in a state in which they can be reliably deployed. During the prepare phase, WebLogic Server instances in the domain complete the following tasks: 1. If necessary, the Administration Server copies deployment files to the target servers staging directories specified by the Staging Directory Name attribute. 2. Each target server validates the deployment files and checks for possible errors to ensure that the files can actually be deployed.
Phase 2: Activate
In the activate phase, target servers make the application available for clients to use. The activate phase constitutes the actual deployment of the application or module. The activation phase only takes place after the prepare phase successfully completes.
4-2
Application-scoped configuration. Certain resources can be configured and scoped for an application. These include connection pools, security realms and XML related resources. See Overview of Application Scoping in Programming WebLogic XML. Improved redeployment. You do not need to undeploy before redeploying. See Redeploying or Stopping a Deployment Unit on page 3-8. Improved API. A simple API separates configuration from the actual deployment operations. When a deployment is requested, this API creates the necessary configuration (MBeans) for you. Also, the deployment operations are not on the MBeans themselves, so you can change the configuration (such as the target lists) without affecting the deployed application, until a deployment request is initiated. See Deployment Management API on page 5-11, and see also the API documentation for weblogic.management.deploy. Deployment status. It is now easier to track the progress of a deployment especially when it has multiple targets. See the WebLogic Administration Console Online Help for Tasks.
2. If the earlier deployment did not have an application.xml file, create one in the applications META-INF subdirectory. 3. Deploy the application using weblogic.Deployer. Enter a command in the following form:
4-3
java weblogic.Deployer -adminurl http://admin:7001 -username weblogic -deploy -name ArchivedEarJar -source C:/MyApps/JarEar.ear -target server1,server2
domain.
-DClusterConstraintsEnabled=false uses the default two-phase deployment behavior for servers in a domain; deployment is ensured only for clustered servers that are reachable by the Administration Server.
You can also set the ClusterConstraintsEnabled option using the Administration Console: 1. Log into the Administration Console for the domain. 2. Select the name of your domain at the top of the left pane. 3. Select the Configuration->General tab in the right pane. 4. Use the Enable Cluster Constraints box to enable or disable cluster constraints for the entire domain. 5. Click Apply and reboot the Administration Server to apply the change.
4-4
Stage Mode
In stage mode, the Administration Server copies the deployment files from their original location on the Administration Server machine to the staging directories of each target server. For example, if you deploy a J2EE Application to three servers in a cluster using stage mode, the Administration Server copies the deployment files to directories on each of the three server machines. Each server then deploys the J2EE Application using its local copy of the archive files. Warning: After you have deployed your application, do not change or remove the original source files for the application. The WebLogic Server deployment framework uses the files to manage deployed applications. Changing or removing the original source files may result in unexpected application behavior. When copying files to the staging directory, the Administration Server creates a subdirectory with the same name as the deployment name. So if you deployed using the command:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password weblogic -name mytestear -stage -targets mycluster -deploy c:\bea\weblogic81\samples\server\medrecd\dist\physicianEar
a new directory, mytestear, would be created in the staging directory of each server in mycluster. If you do not specify a deployment name, a default deployment name (and staging subdirectory) is used: For exploded archive deployments, the deployment name and staging subdirectory are the name of the directory you deployed (physicianEar in the example above). For archived deployments, the default deployment name is the name of the archive file without the extension. For example, if you deploy physicianEar.ear, the deployment name and staging subdirectory are physicianEar.
4-5
The Administration Console uses stage mode as the default mode when deploying to more than one WebLogic Server instance. weblogic.Deployer uses the target servers staging mode as the default, and managed servers use stage mode by default. Stage mode ensures that each server has a local copy of the deployment files on hand, even if a network outage makes the Administration Server unreachable. However, if you are deploying very large applications to multiple servers or to a cluster, the time required to copy files to target servers can be considerable. You may consider nostage mode to avoid the overhead of copying large files to multiple servers.
Nostage Mode
In nostage mode, the Administration Server does not copy the archive files from their source location. Instead, each target server must access the archive files from a single source directory for deployment. The staging directory of target servers is ignored for nostage deployments. For example, if you deploy a J2EE Application to three servers in a cluster, each server must be able to access the same application archive files (from a shared or network-mounted directory) to deploy the application. Note: The source for the deployment files in nostage mode is the path provided by the user at deployment time (as opposed to stage mode, where the source is the path in each servers staging directory). However, even in nostage mode, WebLogic Server copies out parts of the deployment to temporary directories. This enables users to update entire archived deployments or parts of archived deployments. In nostage mode, the Web Application container automatically detects changes to JSPs and servlets. Nostage also allows you to later update only parts of an application by updating those parts in one file system location and then redeploying. The Administration Console uses nostage mode as the default when deploying only to the Administration Server (for example, in a single-server domain). weblogic.Deployer uses the target servers staging mode, and Administration Servers use stage mode by default. You can also select nostage mode if you run a cluster of server instances on the same machine, or if you are deploying very large applications to multiple machines that have access to a shared directory. Deploying very large applications in nostage mode saves time during deployment because no files are copied.
External_stage mode
External_stage mode is similar to stage mode, in that target servers deploy using local copies of the deployment files. However, the Administration Server does not automatically copy the
4-6 Deploying WebLogic Server Applications
De plo y me nt Or der
deployment files to targeted servers in external_stage mode; instead, you must copy the files to the staging directory of each target server before deployment. You can perform the copy manually or using automated scripts. Within each target servers staging directory, deployment files must be stored in a subdirectory that reflects the deployment name. This can either be the name you type in for the deployment, or the default deployment name (the name of the exploded archive directory, or the name of the archive file without its file extension). See Deploying an Enterprise Application Using external_stage Mode on page 3-13 for an example. External_stage mode is the least common deployment staging mode. It is generally used only in environments that are managed by third-party tools that automate the required copying of files. You may also choose to use external_stage mode when you are deploying very large applications to multiple machines and you do not have a shared file system (and cannot use nostage mode). Using external stage in this scenario decreases the deployment time because files are not copied during deployment.
Deployment Order
By default, WebLogic Server deploys server-level resources (JDBC followed by JMS) before deploying applications and standalone modules, followed by startup classes. (The order of startup class execution is configurable, as described in Ordering Startup Class Execution and Deployment on page 4-8.) Note: WebLogic Server security services are always initialized before server resources, applications, and startup classes are deployed. For this reason, you cannot configure custom security providers using startup classes, nor can custom security provider implementations rely on deployed server resources such as JDBC. The deployment order of deployment units relative to one another is determined by the Load Order attribute. By default, each deployment unit is configured with a Load Order value of 100.
Deploying WebLogic Server Applications 4-7
Deployments with a lower Load Order value are deployed before those with a higher value during startup. Deployments with the same Load Order value are deployed in alphabetical order using the deployment name. You can change the load order for a deployment unit by setting the Load Order attribute in the Administration Console or programmatically using the ApplicationMBean. See Changing the Order of Deployment for a Deployment Unit on page 3-15 for instructions on changing the Load Order using the Administration Console.
4-8
De plo y me nt Or der
java weblogic.Server Execute Startup Classes with Run Before Application Deployments Initialize JDBC/JMS Services Execute Startup Classes with Run Before Application Activation Deploy Applications and Standalone Modules Execute Startup Classes (Default Behavior) BEA provides the examples.jms.startup API code example which demonstrates how to establish a JMS message consumer from a WebLogic startup class.See the Administration Console Online Help or the full Javadocs for StartupClassMBean for more information. Note: WebLogic Server 8.1optionally installs API code examples in WL_HOME\samples\server\examples\src\examples, where WL_HOME is the top-level directory of your WebLogic Server installation. You can start the examples server, and obtain information about the samples and how to run them.
Developing WebLogic Server Applications for more information on classloading behavior. Individual files in a Web Application (for instance, a servlet, JSP, or static HTML page) can also be redeployed independently of the rest of the application, without affecting the application classloaders. See Redeploying or Stopping a Deployment Unit on page 3-8 and Redeploying Static Files in a Web Application on page 3-17 for example instructions on redeploying applications and modules.
4-10
If you redeploy a module of an Enterprise Application that affects other modules (because of classloader dependencies), you must explicitly redeploy the entire application. weblogic.Deployer displays the message:
Exception:weblogic.management.ApplicationException: [J2EE:160076] You must include all of [module_list] in your files list to modify [module]
You can not redeploy stale files (files that are older than the currently deployed files based on the timestamp of the compiler). If you need to revert to an older version of your deployment (maintaining the original timestamp), you must undeploy the currently deployed files and then deploy the older version of the files.
4-11
archive or directory.) You identify the external EAR descriptor file at deployment time, and WebLogic Server uses the alternate file in place of the deployments existing (packaged) deployment descriptor. If the files are deployed using stage mode, alternate deployment descriptor files are copied with the deployment files to the top level of the deployments subdirectory in each target servers staging directory (for example, domain_directory/servername/stage/myapp). With other staging modes, no copying is performed. You can specify an alternate deployment descriptor file to use in place of either the standard J2EE deployment descriptor (application.xml) or the WebLogic Server deployment descriptor (weblogic-application.xml).
4-12
See Deploying an Enterprise Application with an Alternate (External) Application Descriptor on page 3-14 for an example of using alternate descriptor files.
Auto-Deployment
Notes: Auto-deployment is a method for quickly deploying an application to a standalone server (Administration Server) for evaluation or testing. It is recommended that this method be used only in a single-server development environment. Use of auto-deployment in a production environment or for deployment on Managed Servers is not recommended. BEA recommends that you use the WebLogic Server split development directory and wldeploy ant task, rather than auto-deployment, when developing an application. See Introducing the Split Development Directory Structure in Developing WebLogic Server Applications. If auto-deployment is enabled, when an application is copied into the \applications directory of the Administration Server, the Administration Server detects the presence of the new application and deploys it automatically (if the Administration Server is running). If WebLogic Server is not running when you copy the application to the \applications directory, the application is deployed the next time the WebLogic Server Administration Server is started. Auto-deployment deploys only to the Administration Server.
4-13
Notes: Due to the file locking limitations of Windows NT, if an application is exploded, all the modules within the application must also be exploded. In other words, you cannot use auto-deployment with an exploded application or module that contains a JAR file. Auto-deployment is intended for use with a single server target in a development environment. If you use other tools, such as the Administration Console, to add targets to an auto-deployed, exploded application, redeploying the application does not propagate changes to the new target servers.
When an application has been auto-deployed in exploded archive format, the Administration Server periodically looks for a file named REDEPLOY in the exploded application directory. If the timestamp on this file changes, the Administration Server redeploys the exploded directory. To redeploy files in an exploded application directory: 1. When you first deploy the exploded application directory, create an empty file named REDEPLOY, and place it in the WEB-INF or META-INF directory, depending on the application type you are deploying: An exploded enterprise application has a META-INF top-level directory; this contains the application.xml file. An exploded Web application has a WEB-INF top-level directory; this contains the web.xml file. An exploded EJB application has a META-INF top-level directory; this contains the ejb-jar.xml file. An exploded connector has a META-INF top-level directory; this contains the ra.xml file. Note: The REDEPLOY file works only for an entire deployed application or standalone module. If you have deployed an exploded Enterprise Application, the REDEPLOY file controls redeployment for the entire applicationnot for individual modules (for example, a Web Application) within the Enterprise Application. If you deploy a Web Application by itself as an exploded archive directory, the REDEPLOY file controls redeployment for the entire Web Application. 2. To redeploy the exploded application, copy the updated files over the existing files in that directory. 3. After copying the new files, modify the REDEPLOY file in the exploded directory to alter its timestamp. When the Administration Server detects the changed timestamp, it redeploys the contents of the exploded directory. Note: You must touch the REDEPLOY file (alter its timestamp) any time you wish to trigger redeployment of an auto-deployed application. Even if you modify an application while a server is shut down, you must touch REDEPLOY to ensure that changes are applied when the server next starts up. To undeploy an application that was auto-deployed in exploded format, use the weblogic.Deployer -undeploy command, or use the Administration Console to remove the deployment configuration. Then remove the application files from the /applications directory.
Deploying WebLogic Server Applications 4-15
The preStart event is the beginning of the prepare phase, or the start of the application deployment process.)
public void postStart(ApplicationLifecycleEvent evt) {}
The postStart event is the end of the activate phase, or the end of the application deployment process. The application is deployed.
public void preStop(ApplicationLifecycleEvent evt) {}
The preStop event is the beginning of the deactivate phase, or the start of the application removal or undeployment process.
public void postStop(ApplicationLifecycleEvent evt) {}
The postStop event is the end of the remove phase, or the end of the application removal or undeployment process. Shutdown classes only get postStop events. Startup classes only get preStart events. Note: For Startup and Shutdown classes, you only implement a main{} method. If you implement any of the methods provided for Listeners, they are ignored. Note: No remove{} method is provided in the ApplicationLifecycleListener, because the events are only fired at startup time during deployment (prestart and poststart) and shutdown during undeployment (prestop and poststop).
4-16
listenerUsed to register user defined application lifecycle listeners. These are classes that extend the abstract base class weblogic.application.ApplicationLifecycleListener. shutdownUsed to register user-defined shutdown classes. startupUsed to register user-defined startup classes.
Basic Functionality
You create a listener by extending the abstract class (provided with WebLogic Server) weblogic.application.ApplicationLifecycleListener. The container then searches for your listener. You override the following methods provided in the WebLogic Server
ApplicationLifecycleListener abstract class to extend your application and add any
required functionality:
preStart{} postStart{} preStop{} postStop{}
Listing 4-1 illustrates how you override the ApplicationLifecycleListener. In this example, the public class MyListener extends ApplicationLifecycleListener. Listing 4-1 MyListener
import weblogic.application.ApplicationLifecycleListener; import weblogic.application.ApplicationLifecycleEvent; public class MyListener extends ApplicationLifecycleListener { public void preStart(ApplicationLifecycleEvent evt) { System.out.println ("MyListener(preStart) -- we should always see you.."); } // preStart public void postStart(ApplicationLifecycleEvent evt) { System.out.println
4-17
("MyListener(postStart) -- we should always see you.."); } // postStart public void preStop(ApplicationLifecycleEvent evt) { System.out.println ("MyListener(preStop) -- we should always see you.."); } // preStop public void postStop(ApplicationLifecycleEvent evt) { System.out.println ("MyListener(postStop) -- we should always see you.."); } // postStop public static void main(String[] args) { System.out.println ("MyListener(main): in main .. we should never see you.."); } // main }
Listing 4-2 illustrates how you implement the shutdown class. The shutdown class is attachable to preStop and postStop events. In this example, the public class MyShutdown extends ApplicationLifecycleListener. Listing 4-2 MyShutdown
import weblogic.application.ApplicationLifecycleListener; import weblogic.application.ApplicationLifecycleEvent; public class MyShutdown extends ApplicationLifecycleListener { public static void main(String[] args) { System.out.println ("MyShutdown(main): in main .. should be for post-stop");
4-18
} // main }
Listing 4-3 illustrates how you implement the startup class. The startup class is attachable to preStart and postStart events. In this example, the public class MyStartup extends ApplicationLifecycleListener. Listing 4-3 MyStartup
import weblogic.application.ApplicationLifecycleListener; import weblogic.application.ApplicationLifecycleEvent; public class MyStartup extends ApplicationLifecycleListener { public static void main(String[] args) { System.out.println ("MyStartup(main): in main .. should be for pre-start"); } // main }
4-19
Listing 4-4 Configuring Application Lifecycle Events Using the URI Parameter
<listener> <listener-class>MyListener</listener-class> <listener-uri>foo.jar</listener-uri> </listener> <startup> <startup-class>MyStartup</startup-class> <startup-uri>foo.jar</startup-uri> </startup> <shutdown> <shutdown-class>MyShutdown</shutdown-class> <shutdown-uri>foo.jar</shutdown-uri> </shutdown>
The following example illustrates how you configure application lifecycle events without using the URI parameter. Listing 4-5 Configuring Application Lifecycle Events without Using the URI Parameter
<listener> <listener-class>MyListener</listener-class> </listener> <startup> <startup-class>MyStartup</startup-class> </startup> <shutdown> <shutdown-class>MyShutdown</shutdown-class>
4-20
</shutdown>
3. Initialization takes place. (Unless you have set debug flags, you do not see the initialization.)
4. preStart{} 5. postStart{}
4-21
4-22
CHAPTER
The following sections describe tools for deploying applications and standalone modules to WebLogic Server: weblogic.Deployer Utility on page 5-1 wldeploy Ant Task on page 5-7 WebLogic Builder on page 5-11 Deployment Management API on page 5-11
weblogic.Deployer Utility
The weblogic.Deployer utility replaces the earlier weblogic.deploy utility, which has been deprecated. The weblogic.Deployer utility is a Java-based deployment tool that provides a command-line interface to the WebLogic Server Deployment Management API on page 5-11. This utility was developed for administrators and developers who need to initiate deployment from the command line, a shell script, or any automated environment other than Java.
5-1
You can also list specific files in the archive that are to be deployed (or redeployed, or undeployed). The file list can include file names and directories relative to the root of the application. If you specify a directory, its entire subtree is deployed or redeployed.
Description
The URL of the Administration Server. Default is http://localhost:7001. The Administrator username. If you supply the -username option but you do not supply a corresponding -password option, weblogic.Deployer prompts you for the password. The password of the Administrator user. To avoid having the plain text password appear in scripts or in process utilities such as ps, first store the username and encrypted password in a configuration file using the STOREUSERCONFIG command with weblogic.Admin. Omit both the -username and -password options to weblogic.Deployer to use the values stored in the default configuration file. See STOREUSERCONFIG in the weblogic.Admin Command-Line Reference for more information on storing and encrypting passwords. If you want to use a specific configuration file and key file, rather than the default files, use the -userconfigfile and -userkeyfile options to weblogic.Deployer.
-password <password>
Specifies the deployment name for the application or standalone module. This can be the name of an existing, configured application or the name to use when creating a new configuration.
5-2
Option
-targets <target list>
Description
A comma-separated list of the target servers and/or cluster names (<server1>,<cluster1>,...). Each target may be qualified with a J2EE module name (<module1>@<server1>). This enables different modules of the archive to be deployed on different servers. For an application that is currently deployed, -targets defaults to all current targets. For an application that you are deploying for the first time, -targets defaults to the Administration Server.
Used after the -redeploy action, this option removes static files from a servers staging directory. delete_files is valid only for unarchived deployments, and only for applications deployed using stage mode. You must specify target servers when using this option, as shown in the following example:
java weblogic.Deployer -adminurl http://myserver:7001 -username weblogic -password weblogic -name myapp -targets myapp@myserver -redeploy -delete_files myapp/tempindex.html delete_files only removes files that WebLogic Server copied to the staging area during deployment. If you use the delete_files option with an application that was deployed using either nostage or external_stage mode, the command does not delete the files. delete_files can only be used in combination with the redeploy action.
Specifies the location of a user configuration file to use for the administrative username and password. Use this option, instead of the -user and -password options, in automated scripts or in situations where you do not want to have the password shown on-screen or in process-level utilities such as ps. Before specifying the -userconfigfile option, you must first generate the file using the weblogic.Admin STOREUSERCONFIG command as described in STOREUSERCONFIG in the weblogic.Admin Command-Line Reference.
5-3
Option
-userkeyfile <path to file>
Description
Specifies the location of a user key file to use for encrypting and decrypting the username and password information stored in a user configuration file (the -userconfigfile option). Before specifying the -userkeyfile option, you must first generate the key file using the weblogic.Admin STOREUSERCONFIG command as described in STOREUSERCONFIG in the weblogic.Admin Command-Line Reference. Displays additional progress messages, including details about the prepare and activate phases of the deployment. Specify either raw or formatted to control the appearance of weblogic.Deployer output messages. Both output types contain the same information, but raw output does not contain embedded tabs. By default, weblogic.Deployer displays raw output. Display debug messages in the standard output. Prints command-line help text for the most commonly-used weblogic.Deployer actions and options. Prints full command-line help text for all weblogic.Deployer actions and options. Display example command lines for common tasks. Transfers the specified source file(s) to the Administration Server. Use this option when you are on a different machine from the Administration Server and you cannot copy the deployment files by other means. The application files are uploaded to the WebLogic Server Administration Servers upload directory prior to deployment. Indicates that weblogic.Deployer is not running on the same machine as the Administration Server, and that source paths specified in the command are valid for the Administration Server machine itself. If you do not use the -remote option, weblogic.Deployer assumes that all source paths are valid paths on the local machine. Does not copy the deployment files to target servers; instead, deploys them from the fixed location specified using the -source option.
nostage is the default when you deploy to the Administration Server (for example, in a single-server domain).
-verbose
-output <raw>
-debug -help
-advanced
-examples -upload
-remote
-nostage
5-4
Option
-stage
Description
Copies deployment files to target servers staging directories before deployment. stage is used as the default when deploying to Managed Server targets.
-external_stage
Does not copy the deployment files to target servers; instead, you must ensure that deployment files have been copied to the correct subdirectory in the target servers staging directories before deployment. You can manually copy the files or use a third-party tool or script.
weblogic.Deployer prints the task ID and exits without waiting for the action to complete. This option is used to initiate multiple tasks and then monitor them later with the -list action.
-nowait
-timeout <seconds>
Specifies the maximum time, in seconds, to wait for the deployment task to complete. After the time expires, weblogic.Deployer prints out the current status of the deployment and exits. Specifies the location of the archive file or exploded archive directory to deploy.
Specifies the name of an alternate J2EE deployment descriptor (application.xml) to use for deployment. Specifies the name of an alternate WebLogic Server deployment descriptor (weblogic-application.xml) to use for deployment. Specifies the task identifier of a running deployment task. You can specify an identifier with the -deploy, -redeploy, or -undeploy actions, and use it later as an argument to the -cancel or -list actions. Make sure that the identifier is unique to all other running deployment tasks. The system automatically generates a unique identifier if you do not specify one. Prints version information.
-altwlsappdd
-version
5-5
Description
Deploys or redeploys an application. Stops the deployment unit and removes staged files and deployment information from all target servers. (You may also use -remove as an alias.) Note: An application becomes unavailable to clients during an undeployment. WebLogic Server doesn't guarantee the operation of the application and deployment task if there is an access from the client at this time.
-redeploy
Replaces a running application or part of a running application. Note: An application becomes unavailable to clients during redeployment. WebLogic Server doesn't guarantee the operation of the application and deployment task if there is an access from the client at this time. For this reason, redeployment is not recommended for use in a production environment.
-stop
Makes an application inactive and unavailable to clients on target servers. The deployment information and staged files remain available on target servers for subsequent -start, -deploy, -redeploy, or -undeploy actions. Makes an inactive application available to clients on target servers. -start does not redistribute deployment files to target servers; the files must already be available via an earlier -deploy or -distribute action. Perform only the activate stage of a deployment by copying deployment files to target server staging directories (if necessary) and registering the deployment name. The application is ready for deployment, but is unavailable to clients on the target server. You can later use the -start action to make the application available to clients.
-start
-distribute
-cancel
Attempts to cancel the task identified by -id if it is not yet completed. Lists the status of the task identified by -id.
-list
5-6
w lde plo y An t Ta sk
Action
-listtask -listapps
Description
Lists running deployment tasks in the domain. Lists all deployment names for applications and standalone modules deployed in the domain.
3. If necessary, add task definitions and calls to the wlserver and wlconfig tasks in the build script to create and start a new WebLogic Server domain. See Using Ant Tasks to Configure a WebLogic Server Domain in the WebLogic Server Command Reference for information about wlserver and wlconfig. 4. Add a call to wldeploy to deploy your application to one or more WebLogic Server instances or clusters. See Sample build.xml Files for wldeploy on page 5-8 and wldeploy Ant Task Reference on page 5-9. 5. Execute the Ant task or tasks specified in the build.xml file by typing ant in the staging directory, optionally passing the command a target argument:
prompt> ant
The following sample shows a more advanced wldeploy target that redeploys a single file in an exploded Web Application:
<target name="redeploy"> <wldeploy action="redeploy" source="c:\myapps\myWebApp\ name="myWebApp" user="weblogic" password="weblogic" verbose="true" adminurl="t3://localhost:7001" debug="true" targets="examplesServer"> <files file="index.jsp"/> </wldeploy> </target>
5-8
w lde plo y An t Ta sk
Description
The deployment action to perform. Valid values are deploy, cancel, undeploy, redeploy, distribute, start, and stop. The URL of the Administration Server. Specifies the name of an alternate J2EE deployment descriptor (application.xml) to use for deployment. Specifies the name of an alternate WebLogic Server deployment descriptor (weblogic-application.xml) to use for deployment. Enable wldeploy debugging messages. Specifies whether the deployment uses external_stage deployment mode. Specifies a file or list of files on which to perform a deployment action (for example, a list of JSPs to redeploy). See Sample build.xml Files for wldeploy on page 5-8. Identification used for obtaining status or cancelling the deployment. The deployment name for the deployed application. Specifies whether the deployment uses nostage deployment mode. Specifies whether wldeploy returns immediately after making a deployment call (by deploying as a background task).
Data Type
String
Required?
No
No No No
No No No
No No No No
5-9
Description
The administrative password. To avoid having the plain text password appear in the build file or in process utilities such as ps, first store a valid username and encrypted password in a configuration file using the weblogic.Admin STOREUSERCONFIG command. Then omit both the username and password attributes in your Ant build file. When the attributes are omitted, wldeploy attempts to login using values obtained from the default configuration file. If you want to obtain a username and password from a non-default configuration file and key file, use the userconfigfile and userkeyfile attributes with wldeploy. See STOREUSERCONFIG in the weblogic.Admin Command-Line Reference for more information on storing and encrypting passwords.
Data Type
String
Required?
No
Specifies whether the server is located on a different machine. This affects how filenames are transmitted. The source file to deploy. Specifies whether the deployment uses stage deployment mode. The list of target servers to deploy to. The maximum time to wait for a deployment to succeed. Specifies whether the source file(s) are copied to the Administration Servers upload directory prior to deployment. The administrative username.
No No No No No No
user
String
No
5-10
Description
Specifies the location of a user configuration file to use for obtaining the administrative username and password. Use this option, instead of the user and password attributes, in your build file when you do not want to have the plain text password shown in-line or in process-level utilities such as ps. Before specifying the userconfigfile attribute, you must first generate the file using the weblogic.Admin STOREUSERCONFIG command as described in STOREUSERCONFIG in the weblogic.Admin Command-Line Reference. Specifies the location of a user key file to use for encrypting and decrypting the username and password information stored in a user configuration file (the userconfigfile attribute). Before specifying the userkeyfile attribute, you must first generate the key file using the weblogic.Admin STOREUSERCONFIG command as described in STOREUSERCONFIG in the weblogic.Admin Command-Line Reference. Specifies whether wldeploy displays verbose output messages. This is a global attribute used by WebLogic Server Ant tasks. It specifies whether the task should fail if it encounters an error during the build. This attribute is set to true by default.
Data Type
String
Required?
No
userkeyfile
String
No
verbose failonerror
boolean Boolean
No No
WebLogic Builder
WebLogic Builder is a WebLogic Server tool for generating and editing deployment descriptors for J2EE applications. It can also deploy applications to single servers. See the WebLogic Builder Online Help.
application. These methods return a DeploymentTaskRuntimeMBean that encapsulates the request and provides the means for tracking its progress. DeploymentTaskRuntimeMBean provides ongoing status of the request through TargetStatus objects, one per target. The WebLogic Server deployment management API is defined by the following WebLogic Server MBeans:
DeployerRuntimeMBeanprogrammatic interface to deployment requests. Deployment requests provided through the DeployerRuntimeMBean manifest the configuration state
into the application and appropriate component configuration MBeans. These MBeans persist the deployment state of applications in the WebLogic Server domain.
DeploymentTaskRuntimeMBeaninterface for encompassing deployment tasks.
The deployment management API is asynchronous. The client must poll the status or utilize ApplicationMBean notifications to determine when the task is complete. For more information about WebLogic Server deployment management APIs, see the
weblogic.management.deploy Javadoc.
5-12