Wednesday, November 25, 2009

Understanding WLST built-in variables . . .[WLST scripting Best Practices (Part-5)]

This post is a continuation of my previous post - in a series of posts about WLST scripting best practices.

Managed Beans (MBeans) are used to represent all the configuration and runtime information about WebLogic Domain, Servers, the applications and services deployed on a WebLogic Server Domain. While you can get all the information from WebLogic MBeans, WLST simplifies the task of building scripts by providing some built-in variables. These WLST variables are initialized and/or modified when you change to online mode (connect to a server), start an edit session etc. to appropriate values.

One of the very useful WLST variable is cmo. cmo stands for current management object. When navigating in WLST you can use cmo to reference the current MBean (object) instance you are navigating into. The cmo value is changed when you navigate to different hierarchy of MBeans under different MBean trees in WebLogic (except jndi tree). The following illustrates the use of cmo.

connect(username, password, url)
print 'Listenport of server1 -> ' + s1.getListenPort()
print 'Listenport of server2 -> ' + s2.getListenPort()

Notice the use of cmo can for invoking operations on the respective MBean object. There are many such variables that will help you to write better and efficient WLST scripts. See here for the list of all the WLST variables.

If you know a variable name you can simply use it in you script. dumpVariables() command can be used to list all the variables and their values.

wls:/testdomain/serverConfig> dumpVariables()
adminHome weblogic.rmi.internal.BasicRemoteRef - hostID: '328889774891021637S:[7001,7001,-1,-1,-1,-1,-1]:testdomain:AdminServer',oid: '259', channel: 'null'
cmgr [MBeanServerInvocationHandler]com.bea:Name=ConfigurationManager,
cmo [MBeanServerInvocationHandler]com.bea:Name=testdomain,Type=Domain
connected true
domainName testdomain

In addition you should also be aware of these WLST variables in order to NOT use them to store your own information. If you do so then WLST will overwrite these variables during your interaction like connect, startEdit etc. So make sure you understand these WLST variables, use them in your scripts and do not use them to store your information.


  1. Bala,
    I have recently started subscribing to this blog and found this blog very interesting.I am a newbie at WLST and doing the following project.
    On a given linux machine with weblogic 10.3 installed, I have multiple unix user accounts created and each user has his own home directory.
    For development and testing purposes every user needs his own weblogic domain to test and I am trying to create a individual domain for every user ih his home directory using WLST script.
    Every user is assigned a port # range that we can use to build his domain .How can I go about this project? I need a simple domain with Adminserver,nodemanager for every domain and later every developer should be able to ore or more managed servers oh is own domain and I need to provide scripts to start/stop domains,managed servers.
    Please advise

  2. these example are only for weblogic 8, they don't work on weblogic 9 or 10 because of mbean changes.

  3. All my examples are validated in WLS 9.x and above. So it will work on 10g or 11g as well.

  4. Hi,

    I recently found your blog and I find it very usefull. Although I think I found a tiny mistake. Last function call at the first source code should be:
    print 'Listenport of server2 -> ' + s2.getListenPort()
    instead of s1.getListenPort()

  5. Hi,
    I desperately need ur help
    I are doing OIM 9101 installation on Red Hat Linux 5.4 64-bit version. I’m using Oracle Database 11g Release 1 and weblogic 10.3.0. The OIM installation fails with the following error.

    Error Detais

    weblogic-setup.xml - line 196

    ***************Exact Error from setup_weblogic.log**********************
    /oracle/OIM_Server/xellerate/setup/setup.xml:443: The following error occurred while executing this line:
    /oracle/OIM_Server/xellerate/setup/weblogic-setup.xml:196: Could not create task or type of type: wlst.
    Ant could not find the task or a class this task relies upon.

    This is common and has a number of causes; the usual
    solutions are to read the manual pages then download and
    install needed JAR files, or fix the build file:
    - You have misspelt ‘wlst’.
    Fix: check your spelling.
    - The task needs an external JAR file to execute
    and this is not found at the right place in the classpath.
    Fix: check the documentation for dependencies.
    Fix: declare the task.
    - The task is an Ant optional task and the JAR file and/or libraries
    implementing the functionality were not found at the time you
    yourself built your installation of Ant from the Ant sources.
    Fix: Look in the ANT_HOME/lib for the ‘ant-’ JAR corresponding to the
    task and make sure it contains more than merely a META-INF/MANIFEST.MF.
    If all it contains is the manifest, then rebuild Ant with the needed
    libraries present in ${ant.home}/lib/optional/ , or alternatively,
    download a pre-built release version from
    - The build file was written for a later version of Ant
    Fix: upgrade to at least the latest release version of Ant
    - The task is not an Ant core or optional task
    and needs to be declared using .
    - You are attempting to use a task defined using
    or but have spelt wrong or not
    defined it at the point of use

    Remember that for JAR files to be visible to Ant tasks implemented
    in ANT_HOME/lib, the files must be in the same directory or on the

    I have set all the needed envi variables, such as JAVA_HOME, ORACLE_HOME, ANT_HOME and much more before running

    I can understand that the problem lies with the ANT version and JAR files. The Ant version We are using is 1.6.5. But, our earlier attempts at resolving the issue has mostly ended in vain.

    Kindly Help me resolve the issue.

    Kindly contact me @

    Any sort of help will be much appreciated.

  6. Hi,

    I don't realy go over your text, but CLASSPATH is set?

  7. Hi Bala..,

    is there a way to display domain name in WLST?