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

Related Topics: Weblogic

Weblogic: Article

WebLogic Administration with WLShell

WebLogic Administration with WLShell

Command-line scripting is a well-known and proven approach to managing enterprise software systems. We can find examples of it in operating systems, databases, and LDAP servers. This approach allows the system administrator to run system commands to manage and monitor the system interactively. It also allows you to run commands in batch mode for predefined and repetitive tasks. Is there anything similar in the J2EE world?

While the JMX specification provides an API to manage systems, it doesn't specify how the JMX client application should look. Currently there are two JMX client applications with WebLogic: the Web-based Administration Console and the weblogic.Admin command-line utility. In addition, WebLogic MBeans are well documented, allowing customers and partners to develop their own JMX clients to access WebLogic.

I started developing WLShell to explore this idea of scripting, without programming, WebLogic administration - a tool that would give WebLogic administrators similar features to those well-known administrative shells available in other enterprise systems (like the Unix shell, Oracle sqlplus, etc.). That initial idea is now a tool that is downloadable from BEA's dev2dev site at http://dev2dev.bea.com/resourcelibrary/ utilitiestools/adminmgmt.jsp.

What is WLShell? It's a command line interpreter that connects to a WebLogic server and translates user commands to JMX calls. To some extent, WLShell works like the telnet program that connects to a Unix system: it connects to a WebLogic server (administration or managed server) and provides access to MBeans. It supplies the commands "connect" and "disconnect" to manage the connection to a server. Once the connection is established, the user can access MBeans attributes and operations through the WLShell commands "get", "set", and "invoke". The user can then access WebLogic MBeans any number of times under the same connection.

MBean names are usually quite long. To make them easier to remember and shorter to type, WLShell uses a file system analogy. This analogy also fits well in a command-line shell (the Unix shell and Windows command line were designed around the file system). MBean names in WebLogic have at a minimum the domain name, a type, and a name. For instance, a JDBC Connection Pool administration MBean can be named as:


In WLShell, according to the file system metaphor, the domain is the drive unit (as in Windows file systems), the MBean type is the subdirectory under root directory, the name of the MBean is the subdirectory under the MBean type directory, and the MBean attributes and operations are nodes (like files) under the MBean directory. The previous MBean is referenced in WLShell as:


The MaxCapacity attribute of this MBean is referred to as:


The previous notation corresponds to the fully qualified MBean name and MBean attribute name. WLShell also supports partial names by allowing navigation through domains (drives), types, and names (directories) with the "cd" command. The current directory and the directory specified by the command will produce the final name. The following script connects to a server and displays directory contents and the MaxCapacity attribute value:

connect localhost:7001 system weblogic
cd JDBCConnectionPool
cd petstorePool
get MaxCapacity

The previous general description will give you a basic idea of WLShell. The operation of the shell should appear pretty straightforward and self-descriptive to the user. Table 1 summarizes the commands available in WLShell.

In the next sections, I'll describe three main tasks that can be done with WLShell by accessing WebLogic MBeans: configuring domains, deploying applications, and monitoring runtime attributes. I'll take two scripts included in the distribution of WLShell (in version 1.4) to illustrate those tasks. The first script (petstore.wlsh) connects to a WebLogic server, configures some resources, and deploys the Petstore application. The second script (monitor.wlsh) monitors different runtime attributes of the server, services, and applications.

Configuring Domains
In WebLogic, the general semantic to create services like JDBC Connection Pools is to create the corresponding Administration MBean. This is what the WebLogic Console does when the user configures a domain. As with the other administrative tools, the general procedure to configure a service in a domain is:

  • Create the Administration MBean that identifies the service.
  • Configure the service by setting MBean attributes to specific values.
  • Deploy the MBean to one or more available servers or clusters by invoking an MBean operation.
  • Save the domain configuration to file "config.xml".

    The example described here can be executed on a WebLogic domain created with the Domain Configuration Wizard in WebLogic version 7. The script assumes the name of the server is "myserver", but this can be changed in the script. Before starting the server, it is necessary to add the PointBase classes to the classpath. The lines to be added to file startWebLogic.cmd can be found in file pointbase.txt, included with the example files. In addition, the PointBase database has to be started before setting up the domain. The included script, startPB.cmd, will start PointBase. Just review these files to make changes if BEA home is installed on a different directory.

    Once a WebLogic Server is running, start WLShell by typing wlsh (or wlsh.sh on Unix) on a different command window. WLShell will first read the commands in the initialization file .wlshrc. This file is used to customize WLShell environment startup. To set up the PetStore application and required WLS services, just type

    read examples/petstore.wlsh

    at WLShell prompt. This command will read and execute the commands in the specified file (the script file is under the examples directory). The script does the following tasks:

    1. Connects to a WebLogic Server
    2. Creates two JDBC Connection Pools
    3. Creates three data sources
    4. Creates a JMS JDBC data store
    5. Creates a JMS server
    6. Creates seven JMS Destinations (six queues and one topic)
    7. Creates a JMS Connection Factory
    8. Uploads and deploys two enterprise applications
    9. Saves the domain configuration to file config.xml
    After running the petstore.wlsh script, the server should be ready to run PetStore application (http://localhost:7001/petstore/main.screen)

    Let's take a closer look at task 2, creation of JDBC Connection Pools. The script has the commands shown in Listing 1.

    The first four lines will create the Administration MBean that will create the JDBC Connection Pool. Once the new pool is created, we set its properties by setting MBean attributes with the "set" command (lines 5 to 9). In these commands, values of types String and Integer are stored in MBean attributes. One attribute in particular, the "Properties" attribute, expects an object of class "java.util.Properties" that will specify the user to connect to the database (line 7). WLShell provides a mechanism to create an object of a particular class from a String object with a notation similar to Java casting. The command in line 9 will create the expected Properties object.

    Finally, the "addTarget" MBean operation is invoked, providing the name of the server Administration MBean where the resource is going to be targeted.

    At the end of the first part of the script we can read:

    invoke $savedom $DOMAIN

    This command invokes an MBean operation with one parameter to save the domain configuration just created. The fully qualified MBean operation name is in the $savedom variable, which was set up at WLShell start up in the ".wlshrc" file. The parameter is the name of the current active domain, which is stored automatically by the shell in the environment variable $DOMAIN when the user connects to a WebLogic server. The previous command would be equivalent to this one:

    invoke weblogic:/Repository/Default/saveDomain petstoreDomain

    An important point to remember is that in WLShell, all text is case sensitive, including MBean types, names, attributes and operations.

    Deploying Applications
    WebLogic version 7 introduces a new deployment model that's more robust and easier to use and provides a Deployer component to deploy J2EE applications. This component has an MBean interface that can be found in our example domain at:


    This MBean exposes several operations to activate and remove applications and WLShell provides scripting access to this MBean. In order to deploy an application, WebLogic must have access to the application file or directory (expanded format). WLShell supplies a command to upload a file to the server file system, very convenient when the administrator has no other access to the remote file system. With these commands we can deploy our application with just four lines (see Listing 2).

    The first line creates an object of type DeploymentData with the name of the server where the application will be activated. The second line uploads the local enterprise application file to the server file system. The result of this invocation is the fully qualified name of the file uploaded to the server file system. That result is stored in the $LAST environment variable, as with any other WLShell command. We will need that file name for the activate operation, so we will store it on the $appfile environment variable (line 3). Line 4 is the command that invokes the Deployer MBean operation to activate the application with the required parameters. The application should be ready to use after that.

    Runtime Monitoring
    WebLogic Server provides another set of MBeans - Runtime MBeans - to monitor runtime attributes of the server, services, and applications. The naming convention for these MBeans consists of the MBean type name ending with "Runtime". As an example, in WLShell Runtime MBeans can be found under the following directories (this is a partial list):


    The second script file in our example, monitor.wlsh, includes a set of commands to monitor some runtime attributes of the server we just set up. To execute those commands, at WLShell prompt type the following command:

    read examples/monitor.wlsh

    The script contains the following monitoring commands:
    1.   A WLShell Explorer, to graphically explore the Domains and MBeans registered in the Administration Server
    2.   Several WLShell Monitors to graphically display the following runtime values:
    a. Throughput
    b. Queue length
    c. Free heap size
    d. Sockets opened
    e. JDBC runtime statistics
    f. Servlet runtime statistics
    g. EJB runtime statistics
    3.   Text-based repetitive monitoring to correlate several runtime statistics

    Figure 1 shows a screen shot of WLShell monitoring PetStore.

    As seen on the script, a WLShell Monitor can be started with the "get -g attribute" command. This will graphically display the numeric value of an attribute over time. Any number of Monitors can be started to display any numeric attribute. This generic approach makes it possible to monitor any numeric MBean attribute in WebLogic, like a custom Execute Queue created in a Domain, runtime attributes of Web, EJB Components, etc.

    An additional option to the "get -g attribute" command, the "-d" parameter, will tell the Monitor to display the difference between the current reading and the last one (delta) instead of the attribute value. This convenient flag allows you to graphically display things like throughput of the execute queue based on the number of requests serviced. Other interesting examples of this type of monitoring are the number of sockets opened on a server, the invocation count of a particular servlet, and the number of transactions committed by an EJB.

    Server Life Cycle
    Server life cycle can also be controlled through WLShell by invoking the corresponding MBean operations. For instance, a server can be shut down with the following command:

    invoke /ServerRuntime/myserver/shutdown

    To start a server with WLShell - the operation to invoke is in the corresponding Administration MBean - the command is:

    invoke /Server/myserver/start

    While this can be done with just one WLShell command, there are other components that have to be properly configured and running. WLShell invokes the operation of the Administration MBean on the Administration Server, the admin server connects to the node manager running on the machine where the server is located, and finally the node manager starts the server.

    Other management operations include pinging the server for availability, suspending and resuming the server, etc. Examples of these operations can be found in WLShell script files under the "scripts" directory.

    Moving Forward
    A typical domain configuration with a few services and applications, like a WebLogic Portal Domain, can easily have over 1,300 MBeans registered. How can a WebLogic administrator know where to go to manage the domain? There are several suggestions that can be helpful. The first source of information is the WebLogic Administration guide, which provides information about MBeans and management tasks. In addition, the WebLogic Console offers help on every manageable attribute on the console, just click the question mark icon on the left of the attribute name and a help window will pop up providing the name of the MBean that contains the attribute and a short description.

    WLShell will also display the description of MBean attributes through the command "get -v attribute" (v stands for verbose) and through the WLShell Explorer ("explore" command).

    WLShell is a command-line shell for WebLogic administration, including domain configuration, monitoring, and server life-cycle control. It provides a generic access mechanism to any MBean in WebLogic, without requiring any Java programming. The simplified, yet complete, notation for MBeans can make a domain configuration and its documentation more concise and less error-prone. It is ideal for repetitive management tasks like setting up services, deploying applications on different servers, and monitoring. It is also convenient for interactive administration.

  • More Stories By Paco Gomez

    Paco Gómez is Principal Systems Architect at BEA Systems. He designs and develops proof-of-concept architectures for BEA customers and prospects. He is co-writer of the first published book about WebLogic and author of wlshell.

    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
    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...
    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...
    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...