Welcome!

IBM Cloud Authors: Elizabeth White, Dalibor Siroky, William Schmarzo, John Worthington, Liz McMillan

Related Topics: IBM Cloud

IBM Cloud: Article

Best Practices in WebSphere Application Packaging and Deployment

Best Practices in WebSphere Application Packaging and Deployment

Most of the time spent in an application development project is in developing and testing the application. Less time is actually spent designing and creating a repeatable and reproducible packaging and deployment model. A well-designed "build, package, and deploy" model has numerous benefits, including improved developer productivity, reduced turnaround time for builds and code fixes, better consistency in application code, and reinforcement of development policies.

In this article I present the best practices to use in packaging and deploying WebSphere applications. The best practices presented here have been applied to small and large enterprise projects with equal success. Although the focus of this article is WebSphere Application Server 3.5, it can be adopted to WebSphere 4.0 as well. I have created a fictitious application called PetStore to illustrate these practices.

What Are Packaging and Deploying?
Packaging is grouping logically-related classes into JAR files and staging these JAR files and related application runtime resources such as HTML and JSP pages, images, and property files into appropriate directories.

Deploying is installing the code on the destination WebSphere Application Server and configuring the application runtime components such as Web Applications, EJBs, servlets, and JSPs in WebSphere.

Characteristics of an Enterprise Application
A typical enterprise application has the following characteristics:

  • It is implemented using servlets, JSPs, and EJBs.
  • It is integrated with one or more enterprise datasources and applications.
  • The source is version managed using version management software such as Rational ClearCase.
  • There are multiple releases of the application. With every release there are new features, enhancements, and bug fixes.
  • It is promoted through multiple stages - development, integration, test, and production.
  • There are frequent (daily, weekly, and monthly) builds and installs within each stage.
  • Developers, not administrators, know how the application components should be configured in WebSphere.
  • Administrators, not developers, deploy the application in WebSphere.

    Objectives of an Effective Packaging and Deploying Model
    To satisfy the above listed characteristics of an enterprise application and to simplify the tasks in deploying such an application, a good packaging and deployment model should meet the following objectives:

  • The same package should be deployable across multiple stages - development through production.
  • The package should be deployable across multiple operating systems - such as NT and Unix - without any change.
  • The configuration of the application in WebSphere should be scripted and the install should either be automated or be executed by administrators.
  • Application environment-specific properties such as datasource locations and authentication information should be configurable during deployment.
  • The deployment model should promote a clear separation between development and administration. That is, developers should define and maintain how the application should be configured in WebSphere and administrators should deploy the application.
  • If multiple Web applications are to be deployed on the same application server, each application's WebSphere configuration should be independent. This way each application can be maintained independently.

    Best Practices
    For the rest of the article I will discuss best practices which, when implemented, will satisfy the characteristics and objectives outlined in the previous sections.

    Planning
    It's always tempting to jump ahead and start building and deploying the application. However, I strongly recommend that you plan all the tasks needed to package and deploy your application before performing them. When planning for an application install in WebSphere you should identify:

    • All application components such as classes, third-party libraries, HTML and JSP pages, images, and property files
    • All enterprise datasources and the connectivity details the application would use during runtime
    • The types of JAR files and what classes make up these JARs
    • The deployment directory structure where the application components will be installed
    JAR Packaging
    Understanding the purpose and behavior of the different classpaths in WebSphere will help you identify the different types of JAR files and what classes go into these. Table 1 lists the WebSphere classpaths and summarizes the types of classes specified on each of these classpaths.

    After looking at the different WebSphere classpaths, it is recommended that you package your classes into one or more JAR files, which fall into the following categories:

    1. Servlets
    2. EJBs
    3. EJB client classes
    4. EJB dependent classes
    5. Classes common to EJBs and Servlets
    6. Application classes that do not fall into any of these categories
    Table 2 lists all the JAR files and the corresponding WebSphere classpaths for the PetStore application.

    Deployment Directory Structure
    Designing a meaningful directory structure for where your application components will be placed will simplify application management and maintenance. Table 3 lists a manageable directory structure for the PetStore application.

    Application Environment Configuration
    Datasource connectivity details change as the application is promoted from development through production. Externalizing these details into property files makes your code portable across stages. If the application uses WebSphere connection pools, maintaining the datasource JNDI names in property files will decouple the references made in application classes from the configuration.

    For each of the stages, development through production, maintain separate sets of environment property files. During deployment, these property files can either be renamed or copied to the location where the application components look for these files.

    Building Applications
    As the number of classes, EJBs, and JAR files increases in your application, it is essential that you have a defined build process. This will ensure that your application is built in exactly the same manner each time a build is executed. You should identify, document, and automate all the steps to building your application as much as possible.

    An automated build process will speed up the promotion of the application from one stage to another. It also removes any issues related to compilation errors and classpath issues that can cause wasted time and money.

    Use build tools such as Ant to create build scripts, which not only compile your classes but also package them into JAR files and create distributable software. Ant is an open source Java-based build tool that lets you construct your build scripts in much the same fashion as the "make" tool in C or C++. You can use a large number of built-in tasks in Ant to create your build scripts. The build scripts, unlike make files, are XML documents. For the majority of applications, the built-in tasks are sufficient. If they're not, you can create your own custom tasks in Java.

    In addition to creating build scripts it is recommended that you run these build scripts against the source located in your software configuration management tool. This ensures that your builds are using the latest version of the checked-in source.

    Configuring Applications in WebSphere
    You can configure an application in WebSphere either interactively, using the WebSphere Administrative Console, or from the command line using the XMLConfig tool. Creating scripts to configure applications offers these benefits:

  • The same XMLConfig scripts can be used to configure the application across multiple stages.
  • Scripts eliminate potential errors that are caused if applications are deployed otherwise.
  • If you have Windows NT in development and Unix in the rest of the stages, the same scripts may be used to configure the application across operating systems.
  • Developers who have the most knowledge of how the application components should be configured can update the XMLConfig scripts and administrators can execute them.
  • If you need to restore a new server in cases of server failure, these scripts can speed up the process dramatically.

    In this article I will not address WebSphere 3.5 security configurations as most applications do not use them and it isn't easy to script the definitions.

    Creating XMLConfig Scripts
    When creating reusable XMLConfig scripts I recommend the following procedure:

    1.   Use the administrative console the first time you are configuring the application in WebSphere.
    2.   Once you have the application tested and you are satisfied with the configuration, create a model from the application server. Models allow you to create configuration that is portable across stages and domains.
    3.   Delete all the clones, including the application server from which the model was created.
    4.   Export the administrative configuration into an XMLConfig file.

    Once you have exported the XMLConfig script file, I recommend that you refactor the script into multiple scripts based on the following guidelines:

    1.   A node configuration script containing node-specific configurations such as the node-dependent classpath
    2.   A datasource configuration script containing datasource and JDBC driver definitions
    3.   A script for virtual host definitions.
    4.   An application server model script containing the application server, EJB container, EJBs, servlet engine, Web applications, and servlet definitions
    5.   If you have multiple Web applications you can create one script for each application that contains the application-specific Web application, EJBs, and servlet definitions
    6.   A script that is used to install JDBC drivers on each node

    Based on these guidelines, you would refactor the XMLConfig script for the PetStore application into multiple scripts as shown in Table 4.

    As a best practice add these scripts to your software configuration management repository and promote them through the various application stages. Also, while packaging the application include these scripts in the package. This way when the package is installed on the destination server, the scripts needed to deploy the application are available on the server.

    Making XMLConfig Scripts Reusable Across Stages
    Once you have created the multiple XMLConfig scripts the next step is to make these scripts reusable across multiple stages. The following elements tie the scripts to a particular stage or environment:

    1.   IP addresses and database aliases used in data source definitions of the resources.xml script
    2.   Authentication details specified on the EJB container, CMP EJBs and Session Manager of the model.xml and petstore.xml scripts
    3.   Host aliases specified as attributes for the virtual host in the vhosts.xml script

    Replace these configuration elements with XMLConfig substitution variables. For example, replace the occurrence of a host IP address with "$HOST_IP$". When executing these scripts, specify the values to substitute for these variables at the command line.

    Making XMLConfig Scripts Portable Across Operating Systems
    There are three major differences between Windows NT and Unix that affect our XMLConfig scripts:

    1.   The path separator: On NT the class path separator is semi-colon ";" and on Unix it is colon ":".
    2.   The directory separator: On NT the directory separator is backslash "\" and on Unix it is the forward slash "/".
    3.   The root drive: On NT you have a root drive letter called C: and on Unix you have none.

    To make the scripts portable across platforms:

    1.   Replace all occurrences of the path separator in the classpaths with the XMLConfig tool's predefined substitution variable $psep$.
    2.   Replace all occurrences of the NT-specific directory separator "\" with "/". The Java virtual machine treats the forward slash as it would treat a backslash on Windows NT.
    3.   If the application is installed on the same drive as Windows NT, you could safely omit the drive letter from the classpath.

    Deploying the Application
    Deploying the application is a two-step process. First, you have to copy the application software to the destination server. Second, you have to import the XMLConfig scripts into WebSphere.

    When importing the scripts, you need to specify the values to substitute for the variables that you used in the scripts. As a best practice, you can create convenient shell scripts that can be used to import the scripts with the appropriate parameters. If you want to run these shell scripts on NT, you could install software such as CygWin, which provides Unix-like utilities for Windows.

    Summary
    If you follow the best practices discussed in this article you can create a clear separation between the responsibilities of developers and administrators, and simplify building, distributing, and configuring WebSphere applications across multiple stages and platforms.

    Resources

  • Gissel, Thomas R. "Understanding WebSphere Classloaders." http://www7.software.ibm.com/vadd-bin/ftpdl?1/ vadc/wsdd/pdf/gisell/UnderstandingWebSphereClassLoaders.pdf. Describes the different classpaths and provides tips on how to package applications.
  • Ant - a Java build tool from Apache: http://jakarta.apache.org/ant/index.html
  • Cygwin - the popular GNU development tools and utilities for Windows: http://sources.redhat.com/cygwin
  • More Stories By Prasad Thammineni

    Prasad Thammineni is the President of jPeople, a leading WebSphere and J2EE
    consulting services firm that offers architecture, mentoring, design,
    development, training, performance assessment and tuning services. He and
    his team have designed numerous J2EE and WebSphere solutions since WebSphere
    1.0 days. He can be reached at prasad@jpeople.com and for more details on
    jPeople go to www.jpeople.com

    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
    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...
    "MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    SYS-CON Events announced today that Telecom Reseller 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, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
    WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
    Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
    "Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    "IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
    "Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
    It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
    A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
    Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
    In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
    "There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
    Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
    To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
    An increasing number of companies are creating products that combine data with analytical capabilities. Running interactive queries on Big Data requires complex architectures to store and query data effectively, typically involving data streams, an choosing efficient file format/database and multiple independent systems that are tied together through custom-engineered pipelines. In his session at @BigDataExpo at @ThingsExpo, Tomer Levi, a senior software engineer at Intel’s Advanced Analytics gr...
    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, it’s about the data consumed and generated. The devices are tools, mechanisms, conduits. In his session at Internet of Things at Cloud Expo | DXWor...
    Everything run by electricity will eventually be connected to the Internet. Get ahead of the Internet of Things revolution. In his session at @ThingsExpo, Akvelon expert and IoT industry leader Sergey Grebnov provided an educational dive into the world of managing your home, workplace and all the devices they contain with the power of machine-based AI and intelligent Bot services for a completely streamlined experience.
    SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...