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

Related Topics: Weblogic

Weblogic: Article


Automate script creation for your WebLogic Server domain configuration

Enterprise software applications are complex, but almost certainly more complex is the underlying software that provides services and resources to these applications. There are different types of software that fall into the latter category, one of those being a Java application server, which of course for this article is the BEA WebLogic Application Server.

In this article I'll examine the use of scripting languages with WebLogic Server and use code generation to facilitate the creation of scripts.

Benefits of Scripting Languages
To be more productive, system administrators create scripts that enable them to rapidly execute repetitive tasks. These scripts can execute tasks for configuration and control. In the case of WebLogic Server, these scripts are used to do things like start and stop servers, or configure some aspect of a server.

BEA WebLogic Server has different types of scripting languages available today, two of which are shipped with WebLogic Server and one of which is an open-source program called WLShell. The two languages that ship with WebLogic Server are weblogic.Admin and WLAnt. The weblogic.Admin utility interprets commands that enable you to accomplish a variety of administrative tasks. The syntax of the language weblogic.Admin understands is proprietary in nature. The WLAnt language is a set of Ant tasks that accomplish tasks similar to those of weblogic.Admin. The WLShell language, while accomplishing similar tasks, is another syntax to learn, but adds an interactive shell for executing commands and interacting with the domain.

As with any programming language, there is a learning curve before you become comfortable with it. This learning process encompasses the language fundamentals and how to effectively use the language to your best advantage. After you learn the language fundamentals, you must then learn how to apply this to the WebLogic Server domain. Let's briefly look at how to apply each of these scripting languages to a WebLogic Server domain entity, the server.

WebLogic Server Domain
The BEA WebLogic Server has many components that provide runtime services and resources to applications running in it. Some of the components you'll find in a WebLogic Server domain are servers, clusters, JDBC Connection Pools, JMS servers, and JMS Queues to name a few. Each of these scripting languages is applied differently to these objects. For example, writing a script to create a WebLogic Server, along with some properties, for each of the languages would look like Listing 1. (Note: Some statements have been omitted for brevity.)

As you can see, each language has a different syntax for doing the same task, but each conceptually works in the same way, and for different types of WebLogic Server entities. Writing and maintaining these scripts can in some cases be a time-consuming process, keeping in mind that you have to be familiar with the syntax. In some cases, you might use scripts to help in the creation of an entirely new domain. Writing such a large script would be a time-consuming and potentially error-prone process.

We can, however, enhance the process of script writing using code-generation, which enables you to:

  • Rapidly create reusable management code snippets
  • Reduce the learning curve of one of the languages
  • Reduce the learning curve of applying the language to the WebLogic Server domain
  • Provide the ability to generate scripts in the language of your choice

    Introducing conf2admin
    conf2admin is a utility that processes a config.xml and produces output in the form of a scripting language. The current implementation includes support for weblogic.Admin, but Ant and WLShell are planned. The primary features of conf2admin are:

  • Runs against offline configuration
  • Generates scripts in the scripting language of your choice
  • Generates an undo file
  • Generates a script for deploying applications in the domain
  • Excludes certain WebLogic Server entities from output

    The BEA WebLogic Server domain configuration is an XML format file that describes the configuration for servers, clusters, and applications to name a few. The conf2admin utility works by executing an XSLT transformation against the config.xml document, and has XSL templates that produce the commands necessary for creating and setting values on WebLogic Server domain entities.

    Figure 1 illustrates the general concept of conf2admin. Before we continue, let's take a brief look at the core technology behind conf2admin, the Extensible Stylesheet Language Transformations or XSLT.


    XSLT is an XML-based transformation language that works by matching templates against markup-like elements and attributes in an XML document. The templates in conf2admin match against elements in the BEA WebLogic Server domain configuration. The output from these templates is the script code that you will execute using weblogic.Admin or some other script interpreter. The following code snippet shows what a template looks like.

    <xsl:template match="//Server">

    <!—specify contents of template here ‡


    XSLT is a good choice for working with an XML-based configuration. We can get document parsing for free from the XML parser, and a parser for the templates. Writing an XSLT template is pretty straightforward. I won't cover the XSLT specification in depth, but will focus on the sections of the stylesheet relevant to the code generation.

    Applying conf2admin to Medrec
    We'll take the conf2admin utility and run it against the WebLogic Server MedRec samples domain configuration. The MedRec sample ships with BEA WebLogic Server and includes a variety of WebLogic Server resources. Depending on which release of BEA WebLogic Server you have, your MedRec domain configuration might be slightly different. We'll run the utility and focus on the MedRecServer and JDBCConnectionPool resources that will be generated. Those resources are represented by entries in the domain configuration that look like Listing 2.

    When you run the conf2admin utility against the MedRec config.xml, the resulting file will be filled with many lines of generated code; the two snippets for our example deal with the server and the JDBCConnectionPool (see Listing 3)

    From the output you can see that a command for CREATE was generated that will create the server. There were also four SET commands created, each representing the set for an attribute on that Server. Listing 4 lists similar results for the JDBCConnectionPool.

    The conf2admin utility matches against elements in the configuration, in this case the server and JDBCConnectionPool elements, and instantiates the template for emitting CREATE commands. The stylesheet does not name the individual elements it looks for; it merely matches against whatever elements it finds. Next, within the template that emits the CREATE commands, conf2admin begins processing attributes and emitting commands to SET properties on the newly created server or JDBCConnectionPool entities. This flow of processing continues until the entire document has been processed.

    The conf2admin utility will also emit some comment blocks, which indicate the source location in the config.xml that the generated code came from. So in the example of the MedRecServer, the comment block looks like this:

    #== Creating MBean of type Server
    #== Origin: /[1]/Domain[1]/Server[1]

    The origin comment indicates the location in the document expressed as an XPath expression. The numbers in brackets are the indices of the element since in some cases there can be several of a particular type.

    Once the output is generated, you can use that file as input into the weblogic.Admin interpreter in batch mode. The documentation for conf2admin describes how to configure it to generate commands for stand-alone interpretation of script commands. The default is to generate commands to be used in batch mode of weblogic.Admin.

    In this article I looked at the scripting languages that are available for BEA WebLogic Server and how you can use code generation to enable quick creation of management scripts. While seemingly powerful, there are some limitations to using XSLT to generate code. It does not include a friendly interface for looping to reprocess parts; instead, you must recursively call a template until you are finished processing. There is also no real concept of flow control within a template.

    The following links may provide you with more details about the technologies and concepts discussed here.

  • conf2admin on dev2dev: http://dev2dev.bea.com/resourcelibrary/utilitiestools/adminmgmt.jsp
  • WLShell: www.wlshell.com
  • WebLogic Admin: http://e-docs.bea.com/wls/docs81/admin_ref/cli.html
  • WebLogic Server Ant tasks: http://edocs.bea.com/wls/docs81/admin_ref/ant_tasks.html
  • XML 1.0 (Second Edition): www.w3.org/TR/REC-xml
  • XPath 1.0: www.w3.org/TR/xpath
  • XSLT 1.0: www.w3.org/TR/xslt
  • More Stories By Mike Jasnowski

    Mike Jasnowski is a senior software engineer on the BEA WebLogic Server Administration Console team. He has been involved in development for almost 20 years and in many industries. Mike is a contributing author to several books and author of JMX Programming (Wiley)

    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.

    @ThingsExpo Stories
    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...
    The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
    DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City. Digital Transformation (DX) is a major focus with the introduction of DXWorldEXPO within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of bus...
    With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, @CloudEXPO and DXWorldEXPO are two of the most important technology events of the year. Since its launch over eight years ago, @CloudEXPO and DXWorldEXPO have presented a rock star faculty as well as showcased hundreds of sponsors and exhibitors! In this blog post, we provide 7 tips on how, as part of our world-class faculty, you can deliver one of the most popular sessions at our events. But before reading...
    DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
    DXWorldEXPO LLC announced today that "Miami Blockchain Event by FinTechEXPO" has announced that its Call for Papers is now open. The two-day event will present 20 top Blockchain experts. All speaking inquiries which covers the following information can be submitted by email to [email protected] Financial enterprises in New York City, London, Singapore, and other world financial capitals are embracing a new generation of smart, automated FinTech that eliminates many cumbersome, slow, and expe...
    DXWorldEXPO LLC announced today that ICOHOLDER named "Media Sponsor" of Miami Blockchain Event by FinTechEXPO. ICOHOLDER give you detailed information and help the community to invest in the trusty projects. Miami Blockchain Event by FinTechEXPO has opened its Call for Papers. The two-day event will present 20 top Blockchain experts. All speaking inquiries which covers the following information can be submitted by email to [email protected] Miami Blockchain Event by FinTechEXPO also offers s...
    DXWorldEXPO | CloudEXPO 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.
    With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
    Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
    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 ...
    Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...
    Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities - ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups.
    The standardization of container runtimes and images has sparked the creation of an almost overwhelming number of new open source projects that build on and otherwise work with these specifications. Of course, there's Kubernetes, which orchestrates and manages collections of containers. It was one of the first and best-known examples of projects that make containers truly useful for production use. However, more recently, the container ecosystem has truly exploded. A service mesh like Istio addr...
    Predicting the future has never been more challenging - not because of the lack of data but because of the flood of ungoverned and risk laden information. Microsoft states that 2.5 exabytes of data are created every day. Expectations and reliance on data are being pushed to the limits, as demands around hybrid options continue to grow.
    Poor data quality and analytics drive down business value. In fact, Gartner estimated that the average financial impact of poor data quality on organizations is $9.7 million per year. But bad data is much more than a cost center. By eroding trust in information, analytics and the business decisions based on these, it is a serious impediment to digital transformation.
    Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
    Digital Transformation: Preparing Cloud & IoT Security for the Age of Artificial Intelligence. As automation and artificial intelligence (AI) power solution development and delivery, many businesses need to build backend cloud capabilities. Well-poised organizations, marketing smart devices with AI and BlockChain capabilities prepare to refine compliance and regulatory capabilities in 2018. Volumes of health, financial, technical and privacy data, along with tightening compliance requirements by...
    As IoT continues to increase momentum, so does the associated risk. Secure Device Lifecycle Management (DLM) is ranked as one of the most important technology areas of IoT. Driving this trend is the realization that secure support for IoT devices provides companies the ability to deliver high-quality, reliable, secure offerings faster, create new revenue streams, and reduce support costs, all while building a competitive advantage in their markets. In this session, we will use customer use cases...
    Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...