Install/deploy application to weblogic admin server – WLST (script/example)

1. What is WebLogic Scripting Tool?

WebLogic Scripting Tool (WLST) is a command-line scripting interface that enables administrators and developers to manage and automate WebLogic Server configurations, deployments, and monitoring tasks. It serves as a powerful tool for interacting with WebLogic Server’s runtime and domain configurations.

WLST uses the Python programming language, providing a flexible environment to create, modify, and monitor domain resources and applications. This scripting tool empowers users to perform administrative tasks efficiently, allowing for the automation of routine operations, which reduces manual effort and potential errors.

2. How to deploy application to WebLogic Server?

  1. Given a application war file (*.war).
  2. We will execute deployment script from wlst console
    • Path of wlst.sh is <MW_HOME>/oracle_common/common/bin/wlst.sh
  3. Connect to admin server using admin server credentials.
  4. Start edit operation to deploy application.
  5. Deploy application to weblogic admin server
  6. Save and activate session.
  7. Disconnect from admin server.

3. WLST Script to install application to weblogic server:

def wlDeploy(username, password, adminURL, appName, appPath):
    try:
        #connect to admin server
        connect(username, password, adminURL)

        #start edit operation
        edit()
        startEdit()

        #start deploying application to admin server
        progress = deploy(appName,appPath,upload='true')
        progress.printStatus()
        save()
        activate(20000,block="true")

        #disconnect from Admin server
        disconnect()
        exit()
    except Exception, ex:
        print ex.toString()
        cancelEdit('y')

#wlDeploy("weblogic","weblogic1","t3://slc07fic.us.oracle.com:7001","myAppName", "/app/restService.war")
wlDeploy("<Admin User Name>","<Password>","<AdminUrl","<App Name>", "<Path of war file>")

4. Output: deploy/install application to weblogic server

Connecting to t3://myserver:7001 with userid weblogic ...
Successfully connected to Admin Server "AdminServer" that belongs to domain "cluster".

Warning: An insecure protocol was used to connect to the server. 
To ensure on-the-wire security, the SSL port or Admin port should be used instead.

Location changed to edit tree.   
This is a writable tree with DomainMBean as the root.   
To make changes you will need to start an edit session via startEdit(). 
For more help, use help('edit').

Starting an edit session ...
Started edit session, be sure to save and activate your changes once you are done.
Deploying application from /home/apps/myAppName.war to targets  (upload=true) ...
You have an edit session in progress, hence WLST will not block for your deployment to complete.
Started the Deployment of Application. Please refer to the returned WLSTProgress object or variable LAST to track the status.
Current Status of your Deployment:
Deployment command type: deploy
Deployment State : running
Deployment Message : [Deployer:149140]The task cannot be processed further until the current edit session is activated. When this occurs, task processing will continue. The user can exit the deployer tool without affecting the task.
Saving all your changes ...
Saved all your changes successfully.
Activating all your changes, this may take a while ... 
The edit lock associated with this edit session is released once the activation is completed.
Activation completed
Disconnected from weblogic server: AdminServer


Exiting WebLogic Scripting Tool.
Scroll to Top