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
    Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
    Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
    René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
    Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
    In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
    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...
    Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
    If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
    Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...
    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...