Skip navigation.
Downloads | Product Documentation | Support

WebLogic Scripting Tool

# Creating and Configuring WebLogic Domains Using WLST Offline

WLST enables you to create a new domain or update an existing domain without connecting to a running WebLogic Server (that is, using WLST offline)—supporting the same functionality as the Configuration Wizard.

You can create new configuration information, and retrieve and change existing configuration information that is persisted in the domain configuration files (located in the `config` directory, for example, `config.xml`) or in a domain template JAR created using Template Builder.

The following sections describe how to create and configure WebLogic domains using WLST offline. Topics include:

- Creating a Domain (Offline)
- Updating an Existing Domain (Offline)
- Creating a Domain Template (Offline)
- Exporting Diagnostic Data (Offline)
- Stepping Through a Sample Script: Creating a Domain Using WLST Offline

For more information about the Configuration Wizard, see Creating WebLogic Domains Using the Configuration Wizard.

Notes: Before creating or updating a domain, you must set up your environment and invoke WLST, as described in Main Steps for Using WLST. You can exit WLST at anytime using the `exit` command, as follows: `exit()`

When using the Configuration Wizard or WLST Offline to create or extend a clustered domain with a template that has applications containing application-scoped JDBC and/or JMS resources, you may need to perform additional steps (after the domain is created or extended) to make sure that the application and its application-scoped resources are targeted and deployed properly in a clustered environment. For more information on the targeting and deployment of application-scoped modules, see Deploying Applications and Modules in Deploying Applications to WebLogic Server.

# Creating a Domain (Offline)

To create a domain using WLST offline, use one of the options described in the following table. The first option enables you to create a domain from a template, quickly and easily, but does not enable you modify the configuration settings defined in the template at the time of creation. The second option enables you to modify the configuration settings when creating the domain.

Table 3-1 Creating a Domain (Offline)

Option | To... | Use the following command(s)... | For more information, see...
--- | --- | --- | ---
1 | Create a new domain using a specified template. | `createDomain(``domainTemplate``,` `domainDir``,` `user``,` `password``)` | createDomain
2 | 1. Open an existing domain template for domain creation | `readTemplate(``templateFileName``)` | readTemplate
2. Modify the domain (optional) | Various commands Note: Because WLST offline enables you to access and update the configuration objects that appear in the configuration files only, if you wish to view and/or change attribute values for a configuration object that is not already persisted in the configuration files as an XML element, you must first create the configuration object. For more information, see create. | Browsing and Accessing Information About the Configuration Bean Hierarchy (Offline) Editing a Domain (Offline).
3. Set the password for the default user, if it is not already set Note: The default username and password must be set before you can write the domain. | `cd('/Security/``domainname``/User/``username``') cmo.setPassword('``password``')` | Stepping Through a Sample Script: Creating a Domain Using WLST Offline
4. Write the domain configuration information to the specified directory | `writeDomain(``domainDir``)` | writeDomain
5. Close the current domain template | `closeTemplate()` | closeTemplate

# Updating an Existing Domain (Offline)

To update an existing domain using WLST offline, you perform the steps defined in the following table.

Table 3-2 Steps for Updating an Existing Domain (Offline)

Step | To... | Use this command... | For more information, see...
--- | --- | --- | ---
1 | Open an existing domain for update | `readDomain(``domainDirName``)` | readDomain
2 | Extend the current domain (optional) | `addTemplate(``templateFileName``)` | addTemplate
3 | Modify the domain (optional) | Various commands Note: Because WLST offline enables you to access and update the configuration objects that appear in the configuration files only, if you wish to view and/or change attribute values for a configuration object that is not already persisted in the configuration files as an XML element, you must first create the configuration object. For more information, see create. | Browsing and Accessing Information About the Configuration Bean Hierarchy (Offline) Editing a Domain (Offline).
4 | Save the domain | `updateDomain()` | updateDomain
5 | Close the domain | `closeDomain()` | closeDomain

## Browsing and Accessing Information About the Configuration Bean Hierarchy (Offline)

To browse and access information about the configuration bean hierarchy using WLST offline, you can perform any of the tasks defined in the following table.

Note: Because WLST offline enables you to access and update the configuration objects that appear in the configuration files only, if you wish to view and/or change attribute values for a configuration object that is not already persisted in the configuration files as an XML element, you must first create the configuration object.

Table 3-3 Displaying Domain Configuration Information (Offline)

To... | Use this command... | For more information, see...
--- | --- | ---
Navigate the hierarchy of configuration beans | `cd(``path``)` | cd
List child attributes or configuration beans for the current configuration bean | `ls([`'`a`'`|` '`c`'`])` | ls
Toggle the display of the configuration bean navigation path information at the prompt | `prompt([`'`off`'`|`'`on`'`])` | prompt
Display the current location in the configuration bean hierarchy | `pwd()` | pwd
Display all variables used by WLST | `dumpVariables()` | dumpVariables
Display the stack trace from the last exception that occurred while performing a WLST action | `dumpStack()` | dumpStack

## Editing a Domain (Offline)

To edit a domain using WLST offline, you can perform any of the tasks defined in the following table.

Note: Because WLST offline enables you to access and update the configuration objects that appear in the configuration files only, if you wish to view and/or change attribute values for a configuration object that is not already persisted in the configuration files as an XML element, you must first create the configuration object.

For more information about:

- Creating MBeans, see "Understanding WebLogic Server MBeans" in Developing Custom Management Utilities with JMX.
- Examples of creating specific types of MBean resources, for example, a JMS or JDBC system resource, refer to the WLST sample scripts installed with your product, as described in WLST Sample Scripts.
- MBeans, their child types, attributes, and operations, see WebLogic Server MBean Reference.

Table 3-4 Editing a Domain

To... | Use this command... | For more information, see...
--- | --- | ---
Assign configuration beans | `assign(``sourceType``,` `sourceName``,` `destinationType``,` `destinationName``)` | assign
Unassign configuration beans | `unassign(``sourceType``,` `sourceName``,` `destinationType``,` `destinationName``)` | unassign
Create and delete configuration beans | `create(``name``,` `childMBeanType``)` `delete(``name``,` `childMBeanType``)` | create delete
Get and set attribute values | `get(``attrName``)` `set(``attrName``,` `value``)` | get set
Set configuration options | `setOption(``optionName, value``)` | setOption
Load SQL files into a database | `loadDB(``dbVersion``,` `connectionPoolName``)` | loadDB

# Creating a Domain Template (Offline)

To create a domain template using WLST offline, perform the steps described in the following table.

Note: You can also use the `pack` command to create a domain template quickly and easily. For more information, see Creating Templates and Domains Using the pack and unpack Commands.

Table 3-5 Steps for Creating a Domain Template (Offline)

Step | To... | Use this command... | For more information, see...
--- | --- | --- | ---
1 | Open an existing domain or template | `readDomain(``domainDirName``)` `readTemplate(``templateFileName``)` | readDomain readTemplate
2 | Set the password for the default user, if it is not already set Note: The default username and password must be set before you can write the domain template. | `cd('/Security/``domainname``/User/``username``') cmo.setPassword('``password``')` | Stepping Through a Sample Script: Creating a Domain Using WLST Offline
3 | Write the domain configuration information to a domain template | `writeTemplate(``templateName``)` | writeTemplate

# Exporting Diagnostic Data (Offline)

To export diagnostic information using WLST offline, use the `exportDiagnosticData` command defined in the following table.

The results are saved to an XML file. For more information about the WebLogic Server Diagnostic Service, see Configuring and Using the WebLogic Diagnostic Service.

Table 3-6 Exporting Diagnostic Data

To... | Use this command... | For more information, see...
--- | --- | ---
Execute a query against the specified log file | `exportDiagnosticData([``options``])` | exportDiagnosticData

# Stepping Through a Sample Script: Creating a Domain Using WLST Offline

The following example steps through a sample script that creates a WebLogic domain using the Basic WebLogic Server Domain template. The sample script demonstrates how to open a domain template; create and edit configuration objects; write the domain configuration information to the specified directory; and close the domain template.

The script shown is installed with your product at `WL_HOME``\common\templates\scripts\wlst\basicWLSDomain.py`, where `WL_HOME` refers to the top-level installation directory for WebLogic Server. See also WLST Offline Sample Scripts for a description of the full set of sample scripts that are installed with your product.

To create a WebLogic domain using the Basic WebLogic Server Domain template:

1. Open an existing domain template (assuming WebLogic Server is installed at `c:/bea/weblogic91`). In this example, we open the Basic WebLogic Server Domain template.

>     readTemplate('c:/bea/weblogic91/common/templates/domains/wls.jar')

Note: When you open a template or domain, WLST is placed into the configuration bean hierarchy for that domain, and the prompt is updated to reflect the current location in the configuration hierarchy. For example:

`wls:/offline/base_domain>`

WebLogic Server configuration beans exist within a hierarchical structure. Similar to a file system, the hierarchies correspond to drives; types and instances are directories; attributes and operations are files. WLST traverses the hierarchical structure of configuration beans using commands such as `cd`, `ls`, and `pwd` in a similar way that you would navigate a file system in a UNIX or Windows command shell. After navigating to an configuration bean instance, you interact with the bean using WLST commands. For more information, see Navigating and Interrogating MBeans.

2. Configure the domain.

1. Configure the Administration Server and SSL port.

>     cd('Servers/AdminServer')
>     set('ListenAddress','')
>     set('ListenPort', 7001)

>     create('AdminServer','SSL')
>     cd('SSL/AdminServer')
>     set('Enabled', 'True')
>     set('ListenPort', 7002)

2. Define the default user password.

>     cd('/')
>     cd('Security/base_domain/User/weblogic')
>     cmo.setPassword('weblogic')

3. Create a JMS Server.

>     cd('/')
>     create('myJMSServer', 'JMSServer')

4. Create a JMS system resource.

>     cd('/')
>     create('myJmsSystemResource', 'JMSSystemResource')
>     cd('JMSSystemResource/myJmsSystemResource/JmsResource/NO_NAME_0')

5. Create a JMS queue and its subdeployment.

>     myq=create('myQueue','Queue')
>     myq.setJNDIName('jms/myqueue')
>     myq.setSubDeploymentName('myQueueSubDeployment')
>     cd('/')
>     cd('JMSSystemResource/myJmsSystemResource')
>     create('myQueueSubDeployment', 'SubDeployment')

6. Create a JDBC data source, configure the JDBC driver, and create a new JDBC user.

>     cd('/')
>     create('myDataSource', 'JDBCSystemResource')
>     cd('JDBCSystemResource/myDataSource/JdbcResource/myDataSource')
>     create('myJdbcDriverParams','JDBCDriverParams')
>     cd('JDBCDriverParams/NO_NAME_0')
>     set('DriverName','com.pointbase.jdbc.jdbcUniversalDriver')
>     set('URL','jdbc:pointbase:server://localhost/demo')

>     set('PasswordEncrypted', 'PBPUBLIC')
>     set('UseXADataSourceInterface', 'false')
>     create('myProps','Properties')
>     cd('Properties/NO_NAME_0')
>     create('user', 'Property')
>     cd('Property/user')
>     cmo.setValue('PBPUBLIC')

>     cd('/JDBCSystemResource/myDataSource/JdbcResource/myDataSource')
>     create('myJdbcDataSourceParams','JDBCDataSourceParams')
>     cd('JDBCDataSourceParams/NO_NAME_0')
>     set('JNDIName', java.lang.String("myDataSource_jndi"))

>     cd('/JDBCSystemResource/myDataSource/JdbcResource/myDataSource')
>     create('myJdbcConnectionPoolParams','JDBCConnectionPoolParams')
>     cd('JDBCConnectionPoolParams/NO_NAME_0')
>     set('TestTableName','SYSTABLES')

7. Target the resources.

>     cd('/')
>     assign('JMSServer', 'myJMSServer', 'Target', 'AdminServer')
>     assign('JMSSystemResource.SubDeployment', 'myJmsSystemResource.myQueueSubDeployment', 'Target', 'myJMSServer')
>     assign('JDBCSystemResource', 'myDataSource', 'Target', 'AdminServer')

3. Save the domain.

>     setOption('OverwriteDomain', 'true')
>     writeDomain('c:/bea/user_projects/domains/wls_testscript')

4. Close the current domain template.

>     closeTemplate()

5. Exit WLST.

>     exit()