YOUR FEEDBACK
More on the Software Assembly Question - Do Design Patterns Help?
Yanic wrote: Hi, > UML and MDA are being changed to be more data and doc...
SOA World Conference
Virtualization Conference
$50 Savings Expire May 23, 2008... – Register Today!

2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts

SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


WebLogic Administration with WLShell

Digg This!

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:

petstoreDomain:Type=JDBCConnectionPool,
Name=petstorePool

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:

petstoreDomain:/JDBCConnectionPool/petstorePool

The MaxCapacity attribute of this MBean is referred to as:

petstoreDomain:/JDBCConnectionPool/petstorePool/
MaxCapacity

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
dir
cd petstorePool
dir
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:

    petstoreDomain:/DeployerRuntime/DeployerRuntime

    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):

    /ApplicationRuntime
    /ExecuteQueueRuntime
    /JDBCConnectionPoolRuntime
    /JVMRuntime
    /ServerRuntime

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

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

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

  • BEA WEBLOGIC LATEST STORIES
    3rd International Virtualization Conference & Expo: Themes & Topics
    From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
    Microsoft To Keynote 4th International Virtualization Conference & Expo
    Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec
    Virtualization Meets DaaS - Desktop-as-a-Service
    After a $1.5 million angel round, Desktone, which was started in 2006 by Eric Pulier, who also started SOA Software, US Interactive and IVT, picked up $17 million in first-round funding about a year ago from Highland Capital Partners, SoftBank Capital, Citrix Systems and the China-base
    Engelbart's Usability Dilemma: Efficiency vs Ease-of-Use
    The mouse was the original idea of Doug Engelbart who was the head of the Augmentation Research Center (ARC) at Stanford Research Institute. Engelbart's philosophy is best embodied, in my opinion, in the design of another device that he invented, the five-finger keyboard - with keys li
    Web 2.0 Is Fundamentally About Empowering People
    'Unlocking content to be remixed into new business value' is the driver of Web 2.0 in the enterprise, says Rod Smith, IBM VP of Emerging Internet Technologies, in this Exclusive Q&A with Jeremy Geelan on the occasion of IBM's release of a new technology created by IBM researchers, code
    Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
    Here is a question that I have been pondering on and off for quite a while: Why do 'cool kids' choose Ruby or PHP to build websites instead of Java? I have to admit that I do not have an answer. Why do I even care? Because I am a Java developer. Like many Java developers, I get along w
    SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
    SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
    Click to Add our RSS Feeds to the Service of Your Choice:
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
    myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
    Publish Your Article! Please send it to editorial(at)sys-con.com!

    Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

    SYS-CON FEATURED WHITEPAPERS

    MOST READ THIS WEEK
    ADS BY GOOGLE
    BREAKING NEWS FROM THE WIRES
    AmberPoint Extends SOA Governance to Apache ServiceMix, BEA AquaLogic Service Bus 3.0, BEA WebLogic Integration, Cisco ACE XML Gateway, JBoss Enterprise Application Platform and Oracle Fusion
    AmberPoint announced today that it has extended the reach of its runtime SOA governance