Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Server Configuration

Tasks may be made easier with WLST

WebLogic Server Scripting Tool (WLST) is a command-line scripting tool that BEA intends to support as part of the WebLogic Server 9.0 release. This tool is available today on BEA Systems' dev2dev Web site and works with BEA WebLogic Server versions 7.0 and 8.1, including all service packs.

Background

There has always been a need for WebLogic Server to support a scripting solution that allows developers and system administrators to perform both simple and complex changes to their WebLogic Server configuration reliably and interactively. Currently, WebLogic Server supports three command-line tools that require a running WebLogic Server instance: weblogic.Admin, weblogic.Deployer, and the WLConfig Ant task tool. Weblogic.Admin and WLConfig are used to make configuration changes and interrogate MBeans, whereas weblogic.Deployer is used strictly for application deployment. There are also other non-supported tools with which users are familiar such as WLShell, Config2Admin, and MBeanExplorer, etc.

There are many use cases where a simple scripting tool would be handy. For example, developers and administrators may need to write scripts to configure a server and want to enhance it with additional configuration elements via loops and other flow-control constructs. A use case like this would propel the need for a scripting language interpreter that can read user scripts and then run them against the WebLogic Server.

WLST makes an attempt to solve some of the challenges that our current WebLogic Server developers and administrators face. These include capturing repeatable configurations primarily aimed at the preparation of an environment (applications and dependencies) as part of a larger, deployment action; sharing complex configuration changes between users at one level of the life cycle or between levels (e.g., between development and staging); and applying the same change, iteratively, across multiple nodes of a topology, or at some other scope. Adding support for user-defined scripting to WebLogic Server greatly enhances the usability, resulting in higher user satisfaction. With WLST, users are able to customize WebLogic Server to suit their needs, ease their routine tasks, and extend added functionality. Repetitive tasks and complex procedures can now be simplified by providing scripts to handle them. With the help of scripts, components can be "glued" together to form applications. The scripting language augments the Java language and supports the accelerated development.

Introduction

The WebLogic Server Scripting Tool is a command-line scripting interface for WebLogic Server. The WLST scripting environment is based on the Java scripting interpreter, Jython. WLST lets you make use of the provided WebLogic Server scripting functions as well as common features of interpreted languages. These include local variables, conditional variables, and flow control statements. WebLogic Server developers and administrators can extend the WebLogic Server scripting language to suit their environmental needs by following the Jython language syntax.

Jython is an implementation of the high-level, dynamic, object-oriented language Python seamlessly integrated with the Java platform. Jython is 100% Pure Java and is easy to learn with a clear and simple syntax. One of the main advantages of Jython is that you can call any Java object from within the Jython interpreter. What this means for a user is that he/she can reuse any Java code or Java tools that he/she had written. I won't delve too much into details about Jython for this article. For more information about Jython, check out www.jython.org.

WLST Flavors

WLST comes in two flavors, offline and online. Offline is used when a user isn't connected to any WebLogic Server instance and is configuring the domain by interacting with the domain file and configuration templates. This functionality is similar to the Configuration Wizard silent mode scripting that is being deprecated in WebLogic Server version 9.0. Online WLST is utilized when a user is connected to a running WebLogic Server instance and makes changes to the configuration artifacts or monitors the runtime data. Today, both online and offline WLST are available as two separate downloadable JARs. For WebLogic Server version 9.0, the functionality of online and offline WLST will be folded into one tool.

Modes of Operation

WLST provides three modes of operation: interactive, script, and embedded modes. In the interactive mode, the users enter commands and view the response on a command-line prompt. This mode is useful for learning the scripting tool and its capabilities. It is also useful for prototyping command syntax to verify the options before building a larger script. An example of an interactive session is shown in Listing 1. Script mode lets the user supply a set of script commands in a file that the tool executes as a program. Listing 2 shows a simple script that can be executed as a program on WLST. Embedded mode is where a user embeds the WLSTInterpreter in a Java application (see Listing 3).

Features

WebLogic Server implements the Java Management Extensions (JMX) 1.0 and all subsystems (JMS, JDBC, Security, etc.) are instrumented as MBeans and contain attributes by which they can be configured, monitored, and managed. All of these MBeans are arranged in a hierarchical fashion with the DomainMBean as the parent to all of the Configuration MBeans and the DomainRuntimeMBean as the parent to all of the Runtime MBeans. A user can navigate to all of the MBeans via WLST by invoking different WLST commands. For simplicity, the navigation is loosely based upon the file notation in any operating system.

Navigation
In OS terms, WLST has three drives: config, runtime, and custom. The config drive hosts all of the Configuration MBeans with DomainMBean as the parent. The runtime drive hosts all of the Runtime MBeans with DomainRuntimeMBean as the parent, and the custom drive hosts all of the Custom (non-WebLogic) MBeans that a user registers in the WebLogic Server. The MBean types or instances are like the directories in which a user can "cd" or navigate into these MBeans to interrogate the attribute names and values or operations (i.e., files). Listing 4 shows an example in which a user navigates to different drives and MBeans to list the attributes and values.

Configuration
A user can easily move resources from one domain to another by using the "configToScript" command. This command takes a config.xml and converts it into a WLST script that can be applied on another domain to create a similar configuration. It also creates a properties file that contains name-value pairs that can be changed to create configurations with different domain names, server names, etc. Listing 5 demonstrates a simple example where a config.xml is converted into a WLST script. The user can also create new configuration information, and retrieve and change existing configuration values that are stored in the domain config.xml file or in a domain template JAR created using Template Builder. Listing 6 demonstrates a simple example where a user reads an existing medrec template to create a medrec domain.

Current Managed Object (cmo)
Whenever a user navigates to an MBean instance, he has access to that MBean object via the cmo variable. This variable holds the MBean's proxy object so that a user can invoke all of the methods or operations that the MBean interface exposes. Listing 7 demonstrates an example where this variable can be used.

Java from WLST
If you have written any utility command-line tools in Java and would like to reuse these in WLST, you can certainly do so. For example, I wrote a simple Java program that queries the MBeanServer and retrieves all of the MBeans that are registered in this server and prints their object names. The advantage of this is that I do not need to throw away this piece of useful code or rewrite the same in Jython. All I have to do is call this program from WLST. Listing 8 shows the program in Java and shows how a user can call this existing Java program from WLST.

Invoking WLST from Ant
There are many users out there using Ant to automate their WebLogic domain configuration and if you would like to embed your WLST configuration scripts into your Ant build files, you can certainly do so. Listing 9 shows a snippet of a build file that invokes WLST to run a script.

Extend WLST Commands
WLST defines a limited set of commonly used or popular commands out of the box, but this does not restrict a user to define custom commands or modules that can be imported into WLST to suit their needs. Listing 10 defines two custom commands - "createServer" and "deleteServer" - that will create and delete a server with the specified name. These commands will be active for the WLST session. Users can also write modules that define several useful functions and can be imported into WLST. Listing 11 shows an example in which a user defines a security class that has utility functions to create a user, change a password, etc.

WLST Module
Often times, users want to use WLST in conjunction with their other Jython modules. This can be done as easily as writing the WLST module to a file and importing it in your Jython modules. Listing 12 demonstrates how to write out the WLST module and use in a Jython module. You can also check out http://dev2dev.bea.com/codelibrary/code/posample.jsp.

WLST in Action

Let's work through a simple use case that demonstrates an end-to-end scenario where WLST fits in naturally. Consider an administrator trying to configure a domain for his developers. Essentially, he would like to create a domain (one admin server) from scratch, start the server, configure managed servers, and cluster and deploy applications. He would also like to monitor the health of these servers via a simple script. The steps involved here are:
  • Create a simple domain (one admin server) from a template and start the server (see Listing 13).
  • Configure two managed servers and a cluster. Add these two managed servers to this cluster and start the cluster after connecting to the running admin server. Also, deploy a simple application to the cluster (see Listing 14).
  • With a simple monitoring script Monitor the server's health (see Listing 15).

Looking Forward

WLST is available today on BEA Systems' dev2dev site. This version of the tool works with WebLogic Server versions 7.0 and 8.1, including all service packs. Support for this tool is provided via the BEA Systems' Management Newsgroups. It will be officially available and supported in WebLogic Server version 9.0, slated for release sometime next year. BEA Systems is also considering retroactive support for WLST for WebLogic Server versions 7.0 and 8.1.

Some of the new features in WLST that you can expect to see are:

  • Deployment via JSR 88 APIs including the editing of deployment plans via WLST
  • Access to all diagnostic framework (new in WebLogic Server 9.0) artifacts via WLST
  • Merging offline WLST (today available as a separate download) with the existing online WLST tool
  • Access to the new (WebLogic Server 9.0) management APIs
  • Support for all new node manager features that are coming in WebLogic Server 9.0

Summary

In this article, I introduced a new tool, the WebLogic Scripting Tool (WLST), that will empower developers and system administrators to conveniently interact with WebLogic Server (both offline and online) and be able to perform actions that achieve configuration changes to WebLogic Server. WLST can be used in an interactive mode, script mode, or in an embedded mode. It provides a generic and simple access to MBeans in WebLogic Server and also defines convenient commands that can be used to monitor the life cycle of a WebLogic Server instance. WLST is built on Jython, which is a 100% Pure Java implementation of the popular Python language.

References

  • Online WLST Tool: http://dev2dev.bea.com/codelibrary/code/wlst.jsp
  • Offline WLST Tool: http://dev2dev.bea.com/codelibrary/code/wlst_offline.jsp
  • Jython's Main Web Site: www.jython.org
  • PO Sample: http://dev2dev.bea.com/codelibrary/code/posample.jsp
  • More Stories By Satya Ghattu

    Satya Ghattu has been with BEA Systems for more than three years as a senior software engineer focusing mainly in the OAM (Operations Administration and Management) area. Prior to BEA he worked as a Java developer/DBA for multiple consulting companies.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    IoT & Smart Cities Stories
    The challenges of aggregating data from consumer-oriented devices, such as wearable technologies and smart thermostats, are fairly well-understood. However, there are a new set of challenges for IoT devices that generate megabytes or gigabytes of data per second. Certainly, the infrastructure will have to change, as those volumes of data will likely overwhelm the available bandwidth for aggregating the data into a central repository. Ochandarena discusses a whole new way to think about your next...
    CloudEXPO | DevOpsSUMMIT | DXWorldEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
    All in Mobile is a place where we continually maximize their impact by fostering understanding, empathy, insights, creativity and joy. They believe that a truly useful and desirable mobile app doesn't need the brightest idea or the most advanced technology. A great product begins with understanding people. It's easy to think that customers will love your app, but can you justify it? They make sure your final app is something that users truly want and need. The only way to do this is by ...
    Digital Transformation and Disruption, Amazon Style - What You Can Learn. Chris Kocher is a co-founder of Grey Heron, a management and strategic marketing consulting firm. He has 25+ years in both strategic and hands-on operating experience helping executives and investors build revenues and shareholder value. He has consulted with over 130 companies on innovating with new business models, product strategies and monetization. Chris has held management positions at HP and Symantec in addition to ...
    DXWorldEXPO LLC announced today that Big Data Federation to Exhibit at the 22nd International CloudEXPO, colocated with DevOpsSUMMIT and DXWorldEXPO, November 12-13, 2018 in New York City. Big Data Federation, Inc. develops and applies artificial intelligence to predict financial and economic events that matter. The company uncovers patterns and precise drivers of performance and outcomes with the aid of machine-learning algorithms, big data, and fundamental analysis. Their products are deployed...
    Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
    Cell networks have the advantage of long-range communications, reaching an estimated 90% of the world. But cell networks such as 2G, 3G and LTE consume lots of power and were designed for connecting people. They are not optimized for low- or battery-powered devices or for IoT applications with infrequently transmitted data. Cell IoT modules that support narrow-band IoT and 4G cell networks will enable cell connectivity, device management, and app enablement for low-power wide-area network IoT. B...
    The hierarchical architecture that distributes "compute" within the network specially at the edge can enable new services by harnessing emerging technologies. But Edge-Compute comes at increased cost that needs to be managed and potentially augmented by creative architecture solutions as there will always a catching-up with the capacity demands. Processing power in smartphones has enhanced YoY and there is increasingly spare compute capacity that can be potentially pooled. Uber has successfully ...
    SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
    When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...