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