Skip navigation.
Downloads | Product Documentation | Support

Administration Console Online Help

# Startup and Shutdown Classes

[Attributes and Console Screen Reference for Startup and Shutdown]

You can use startup and shutdown classes to configure a WebLogic Server to perform tasks when you start or gracefully shut down the server. A startup class is a Java program that is automatically loaded and executed when a WebLogic Server is started or restarted. For information about when WebLogic Server loads and executes startup classes, see "Ordering Startup Class Execution and Deployment."

A shutdown class is a Java program that is automatically loaded and executed when the WebLogic Server is shut down either from the Administration Console or the `weblogic.admin` `shutdown` command. For more information about when a server invokes startup and shutdown classes, refer to "Server Lifecycle."

To use startup or shutdown classes, you must configure and assign them to servers or clusters. BEA provides the `examples.jms.startup` API code example which demonstrates how to establish a JMS message consumer from a WebLogic startup class.

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.

The following sections describe how to use startup and shutdown classes:

- Configuring a Server to Use a Startup or Shutdown Class: Main Steps
- Modify an Existing Startup or Shutdown Configuration
- Delete a Startup or Shutdown Class Configuration

# Configuring a Server to Use a Startup or Shutdown Class: Main Steps

To configure a server instance to use a startup or shutdown class, complete the following tasks:

1. Configure a Startup or Shutdown Class or Clone a Configuration of a Startup or Shutdown Class.
2. Assign a Startup or Shutdown Configuration to Servers or Clusters.
3. Add the Class to the Server's Classpath.

## Configure a Startup or Shutdown Class

1. In the left pane, expand the Deployments folder.
2. Click on the name of the Startup & Shutdown folder. (See Figure 360-1.)

Figure 360-1 Click on the Name of the Startup & Shutdown Folder

The Administration Console displays the Startup & Shutdown page. This page includes a list of the configurations that already exist in this domain. If any existing configuration is similar to the one that you want to create, consider cloning it. For more information, refer to Clone a Configuration of a Startup or Shutdown Class.

3. On the Startup & Shutdown page, do one of the following:

- To configure a startup class, click the Configure a New Startup Class text link.
- To configure a shutdown class, click the Configure a New Shutdown Class text link.

The Administration Console displays the set of tabs that you use to configure a startup or shutdown class.

4. Enter values in the Name, Class Name, Deployment Order, and Arguments attribute fields. For more information about each field, refer to Attributes for startup classes or Attributes for shutdown classes.

In the Arguments field, separate multiple arguments with a comma. For example,
`firstname=MyFirst,lastname=MyLast`

Do not use spaces to separate the arguments; use only a comma.

5. If you want a startup class to load and execute:

- Before a server instance activates JMS and JDBC services, applications and EJBs, select the Run Before Application Deployments checkbox.
- After a server instance activates JMS and JDBC services, and before it starts deployment for EJBs and applications, select the Run Before Application Activations checkbox.
- After a server instance activates JMS and JDBC services, EJBs, and applications, clear both checkboxes.

6. Click Create.

The Administration Console adds your new configuration under the Startup & Shutdown node in the left pane.

7. If you want to add a note that describes your configuration, click the Notes tab. Enter a note and click Apply.

When you are ready to make the configured class available to one or more servers, refer to Assign a Startup or Shutdown Configuration to Servers or Clusters.

## Clone a Configuration of a Startup or Shutdown Class

1. In the left pane, click the Startup & Shutdown node.

The Administration Console displays the Startup & Shutdown page. This page displays a list of the configurations that already exist in this domain.

2. On the Startup & Shutdown page, click the Clone icon in the row of the class you want to clone.

The Administration Console displays the set of tabs that you use to configure a startup or shutdown class.

3. Enter a value in the Name field.
4. You can modify any of the values in the Class Name, Deployment Order, and Arguments attribute fields. You can also change the setting for the Abort Startup on Failure checkbox.
5. Click Clone to create a configuration with the name that you specified in the Name field.

The Administration Console adds your new configuration under the Startup & Shutdown node in the left pane.

6. If you want to add or modify a note that describes your configuration, click the Notes tab. Enter a note and click Apply.

When you are ready to make the new configuration class available to one or more servers, refer to Assign a Startup or Shutdown Configuration to Servers or Clusters.

## Assign a Startup or Shutdown Configuration to Servers or Clusters

1. In the left pane, expand the Startup & Shutdown folder and click a configuration.

The Administration Console displays the configuration in the right pane.

2. In the right pane, click the Target and Deploy tab.

If you have configured a cluster for the domain, the Target and Deploy tab displays a Clusters table, which lists all servers that are assigned to the cluster.

3. To assign a startup or shutdown class to servers that are in a cluster, do the following:

1. On the Target and Deploy tab, in the Clusters table, select the check box next to the cluster.
2. To assign the class to all servers in the cluster, click the All Servers in the Cluster button. (See Figure 360-2.)
3. To assign the class only to one or more specific servers, click the Part of the Cluster button. Then select the servers you want to target.

When you deploy to all or part of a cluster, the Administration Console initiates a two-phase deployment. In general, such a deployment ensures that if the deployment fails for one active server, it fails for all active servers. For more information, refer to "Introduction to Two-Phase Deployment" and "Guidelines for Deploying to a Cluster."

Figure 360-2 Deploy to an Entire Cluster

4. To assign the startup or shutdown class to servers that are not in a cluster, in the Independent Servers table, select one or more servers.

If the deployment fails for one server, the Administration Console reports the error but continues deploying on any remaining servers that you selected.

5. Click Apply.
6. If you have not already done so, Add the Class to the Server's Classpath.

Note that clicking Apply sets the value of the Server (or Cluster)—>Deployments—>Startup/Shutdown list for each server or cluster that you specified.

## Add the Class to the Server's Classpath

The startup or shutdown class must be on the classpath of each server to which it is assigned. To add a class to a server's classpath, do one of the following:

- If you use a script to start a server instance, open the script in a text editor. In the command that sets the classpath, add the pathname of the directory that contains your class's root package. Then restart the server.

For example, you create a startup class named `StartBrowser` in a package named `com.mycompany.startup`. You archive the class file in a JAR file named `c:`\`myDomain\src\myJAR.jar`. The start script for your server must add `c:\myDomain\src\myJAR.jar` to the server's classpath.

- If you use the Node Manager to start a server instance, do the following:

1. In the left pane of the Administration Console, expand the Servers folder.
2. Click on the name of the server.
3. In the right pane, click the Configuration tab. Then click the Remote Start tab.
4. In the Classpath field, enter the classes that WebLogic Server requires to be on the classpath.

For example, `weblogic.jar` must be on the classpath. For a complete list, refer to Setting the Classpath. Use an absolute pathname or a pathname that is relative to the Node Manager's home directory.

Separate multiple classes with the type of separator that your operating system or shell requires. For example, on Windows, use `;` (semicolon) and in a BASH shell, use `:` (colon).

5. In the Classpath field, add your class to the classpath.

For example, you create a startup class named `StartBrowser` in a package named `com.mycompany.startup`. You archive the class file in a JAR file named `c:\myDomain\src\myJAR.jar`. The start script for your server must add `c:\myDomain\src\myJAR.jar` to the server's classpath.

The following values in the Classpath field register the required classes and your `StartBrowser` startup class:

`c:\bea\weblogic810\server\lib\weblogicsp.jar;c:\bea\weblogic810\server\lib\weblogic.jar;c`:\`myDomain\src\myJAR.jar`

6. Restart the server.

# Modify an Existing Startup or Shutdown Configuration

1. In the left pane, expand the Startup & Shutdown node and click a configuration.

The Administration Console displays the configuration in the right pane.

2. On the Configuration tab, modify any of the values in the Class Name, Deployment Order, and Arguments attribute fields. You can also change the settings for the Failure is fatal or Run before application deployments checkboxes.
3. Click Apply to save any changes.
4. On the Notes tab, modify or add a note.
5. Click Apply to save any changes.
6. On the Targets tab reassign the configuration to different clusters or servers. To remove the configuration from a target, select the target in the Chosen column and click the mover control to move it to the Available column.
7. Click Apply to save any changes.

# Delete a Startup or Shutdown Class Configuration

1. In the left pane, click the Startup & Shutdown node.

The Administration Console displays the Startup & Shutdown page. This page displays a list of the configurations that already exist in this domain.

2. On the Startup & Shutdown page, click the Delete icon in the row of a configuration.

A dialog displays in the right pane asking you to confirm your deletion request.

3. Click Yes to delete the configuration.