Deploying your Applications on WebSphere Application Server 7.0 (Part 1)

Exclusive offer: get 50% off this eBook here
WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide — Save 50%

Manage and administer your IBM WebSphere application server to create a reliable, secure, and scalable environment for running your applications with this book and eBook

$29.99    $15.00
by Steve Robinson | August 2009 | Java

After installing an application server, we would want to deploy applications. Applications can be installed manually or in an automated fashion using scripts. In this two-part article by Steven Charles Robinson, we will cover how to manually deploy a J2EE (Enterprise Edition) application. As we walk through this article, we will show you how to deploy two applications. One application does not require database connectivity; the second is a database aware application which requires some WebSphere configuration to provide database connectivity to the application.

In this article, we will cover the following topics:

  • Application server internals
  • The web container
  • Virtual hosts
  • WebSphere ports
  • Data sources
  • Java Naming and Directory Interface (JNDI)
  • Application deployment
  • J2EE applications
  • Enterprise Archive (EAR)
  • Web Archive (WAR)
  • Java Archive (JAR)

Inside the Application Server

Before we look at deploying an application, we will quickly run over the internals of WebSphere Application Server (WAS). The anatomy of WebSphere Application Server is quite detailed, so for now, we will briefly explain the important parts of WebSphere Application Server.

The figure below shows the basic architecture model for a WebSphere Application Server JVM.

WebSphere Application Server 7.0 Administration Guide

An important thing to remember is that the WebSphere product code base is the same for all operating-systems (platforms). The Java applications that are deployed are written once and can be deployed to all versions of a given WebSphere release without any code changes.

JVM

All WebSphere Application Servers are essentially Java Virtual Machines (JVMs). IBM has implemented the J2EE application server model in a way which maximizes the J2EE specification and also provides many enhancements creating specific features for WAS. J2EE applications are deployed to an Application Server.

Web container

A common type of business application is a web application. The WAS web container is essentially a Java-based web server contained within an application server's JVM, which serves the web component of an application to the client browser.

Virtual hosts

A virtual host is a configuration element which is required for the web container to receive HTTP requests. As in most web server technologies, a single machine may be required to host multiple applications and appear to the outside world as multiple machines. Resources that are associated with a particular virtual host are designed to not share data with resources belonging to another virtual host, even if the virtual hosts share the same physical machine. Each virtual host is given a logical name and assigned one or more DNS aliases by which it is known. A DNS alias is the TCP/ host name and port number that are used to request a web resource, for example: <hostname>:9080/<servlet>.

By default, two virtual host aliases are created during installation. One for the administration console called admin_host and another called default_host which is assigned as the default virtual host alias for all application deployments unless overridden during the deployment phase. All web applications must be mapped to a virtual host, otherwise web browser clients cannot access the application that is being served by the web container.

Environment settings

WebSphere uses Java environment variables to control settings and properties relating to the server environment. WebSphere variables are used to configure product path names, such as the location of a database driver, for example, ORACLE_JDBC_DRIVER_PATH, and environmental values required by internal WebSphere services and/or applications.

Resources

Configuration data is stored in XML files in the underlying configuration repository of the WebSphere Application Server. Resource definitions are a fundamental part of J2EE administration. Application logic can vary depending on the business requirement and there are several types of resource types that can be used by an application. Below is a list of some of the most commonly used resource types.

Resource Types

Description

JDBC (Java database connectivity)

Used to define providers and data sources

URL Providers

Used to define end-points for external services for example web services...

JMS Providers

Used to defined messaging configurations for Java Message Service, MQ connection factories and queue destinations etc.

Mail Providers

Enable applications to send and receive mail, typically use the SMTP protocol.

JNDI

The Java Naming and Directory Interface (JNDI) is employed to make applications more portable. JNDI is essentially an API for a directory service which allows Java applications to look up data and objects via a name. JNDI is a lookup service where each resource can be given a unique name. Naming operations, such as lookups and binds, are performed on contexts. All naming operations begin with obtaining an initial context. You can view the initial context as a starting point in the namespace. Applications use JNDI lookups to find a resource using a known naming convention. Administrators can override the resource the application is actually connecting to without requiring a reconfiguration or code change in the application. This level of abstraction using JNDI is fundamental and required for the proper use of WebSphere by applications.

Application file types

There are three file types we work with in Java applications. Two can be installed via the WebSphere deployment process. One is known as an EAR file, and the other is a WAR file. The third is a JAR file (often re-usable common code) which is contained in either the WAR or EAR format. The explanation of these file types is shown in the following table:

File Type

Description

JAR file

A JAR file (or Java ARchive) is used for organising many files into one. The actual internal physical layout is much like a ZIP file. A JAR is  generally used to distribute Java classes and associated metadata. In J2EE applications the JAR file often contains utility code, shared libraries and  EJBS. An EJB is a server-side model that encapsulates the business logic of an application and is one of several Java APIs in the Java Platform, Enterprise Edition with its own specification. You can visit http://java.sun.com/products/ejb/ for information on EJBs.

EAR file

An Enterprise Archive file represents a J2EE application that can be deployed in a WebSphere application server. EAR files are standard Java archive files (JAR) and have the file extension .ear. An EAR file can consist of the following:

  • One or more Web modules packaged in WAR files.
  • One or more EJB modules packaged in JAR files
  • One or more application client modules
  • Additional JAR files required by the application
  • Any combination of the above

The modules that make up the EAR file are themselves packaged in archive files specific to their types. For example, a Web module contains Web archive files and an EJB module contains Java archive files. EAR files also contain a deployment descriptor (an XML file called application.xml) that describes the contents of the application and contains instructions for the entire application, such as security settings to be used in the run-time environment...

WAR file

A WAR file (Web Application) is essentially a JAR file used to encapsulate a collection of JavaServer Pages (JSP), servlets, Java classes, HTML and other related files which may include XML and other file types depending on the web technology used. For information on JSP and Servlets, you can visit http://java.sun.com/products/jsp/.

  • Servlets can support dynamic Web page content; they provide dynamic server-side processing and can connect to databases.
  • Java ServerPages (JSP) files can be used to separate HTML code from the business logic in Web pages. Essentially they too can generate dynamic pages; however, they employ Java beans (classes) which contain specific detailed server-side logic.

A WAR file also has its own deployment descriptor called "web.xml" which is used to configure the WAR file and can contain instruction for resource mapping and security.

When an EJB module or web module is installed as a standalone application, it is automatically wrapped in an Enterprise Archive (EAR) file by the WebSphere deployment process and is managed on disk by WebSphere as an EAR file structure. So, if a WAR file is deployed, WebSphere will convert it into an EAR file.

Deploying an application

As WebSphere administrators, we are asked to deploy applications. These applications may be written in-house or delivered by a third-party vendor. Either way, they will most often be provided as an EAR file for deployment into WebSphere. For the purpose of understanding a manual deployment, we are now going to install a default application. The default application can be located in the <was_root>/installableApps folder. The following steps will show how we deploy the EAR file.

Open the administration console and navigate to the Applications section and click on New Application as shown below:

WebSphere Application Server 7.0 Administration Guide

You now see the option to create one of the following three types of applications:

Application Type

Description

Enterprise Application

WebSphere Application Server 7.0 Administration Guide

EAR file on a server configured to hold installable Web Applications, (WAR), Java archives, library files, and other resource files.

Business Level Application

WebSphere Application Server 7.0 Administration Guide

A business-level application is an administration model similar to a server or cluster. However, it lends itself to the configuration of applications as a single grouping of modules.

Asset

WebSphere Application Server 7.0 Administration Guide

An asset represents one or more application binary files that are stored in an asset repository such as Java archives, library files, and other resource files. Assets can be shared between applications.

Click on New Enterprise Application.

As seen in the following screenshot, you will be presented with the option to either browse locally on your machine for the file or remotely on the Application Server's file system. Since the EAR file we wish to install is on the server, we will choose the Remote file system option.

It can sometimes be quicker to deploy large applications by first using Secure File Transfer Protocol (SFTP) to move the file to the application server's file system and then using remote, as opposed to transferring via local browse, which will do an HTTP file transfer which takes more resources and can be slower.

The following screenshot depicts the path to the new application:

WebSphere Application Server 7.0 Administration Guide

Click Browse.... You will see the name of the application server node. If there is more than one profile, select the appropriate instance. You will then be able to navigate through a web-based version of the Linux file system as seen in the following screenshot:

WebSphere Application Server 7.0 Administration Guide

Locate the DefaultApplication.ear file. It will be in a folder called installableApps located in the root WebSphere install folder, for example, <was_root>/installableApps as shown in the previous screenshot.

Click Next to begin installing the EAR file.

On the Preparing for the application installation page, choose the Fast Path option. There are two options to choose.

Install option

Description

Fast Path

The deployment wizard will skip advanced settings and only prompt for the absolute minimum settings required for the deployment.

Detailed

The wizard will allow, at each stage of the installation, for the user to override any of the J2EE properties and configurations available to an EAR file.

The Choose to generate default bindings and mappings setting allows the user to accept the default settings for resource mappings or override with specific values. Resource mappings will exist depending on the complexity of the EAR. Bindings are JNDI to resource mappings. Each EAR file has pre-configured XML descriptors which specify the JNDI name that the application resource uses to map to a matching (application server) provided resource. An example would be a JDBC data source name which is referred to as jdbc/mydatasource, whereas the actual data source created in the application server might be called jdbc/datasource1. By choosing the Detailed option, you get prompted by the wizard to decide on how you want to map the resource bindings. By choosing the Fast Path option, you are allowing the application to use its pre-configured default JNDI names.

We will select Fast Path as demonstrated in the following screenshot:

WebSphere Application Server 7.0 Administration Guide

Click on Next.

In the next screen, we are given the ability to fill out some specific deployment options. Below is a list of the options presented in this page.

WebSphere Application Server 7.0 Administration Guide Manage and administer your IBM WebSphere application server to create a reliable, secure, and scalable environment for running your applications with this book and eBook
Published: August 2009
eBook Price: $29.99
Book Price: $49.99
See more
Select your format and quantity:

Option value

Description/Values

Precompile JavaServer Pages files 

Specify whether to precompile JavaServer Pages (JSP) files as a part of installation. The default is not to precompile JSP files.

Directory to install application

Specifies the directory to which the enterprise application (EAR) file will be installed.

You can change this if you want the application to be physically located outside of the WebSphere file structure.

Distribute application

The default is to enable application distribution. You can override this and choose to not distribute the application across multiple nodes.

Default = true

Use Binary Configuration

Specifies whether the application server uses the binding, extensions, and deployment descriptors located within the application deployment document, the deployment.xml file (default), or those located in the enterprise application resource (EAR) file.

Default = false

Deploy enterprise beans

The tool generates the code needed to run enterprise bean (EJB) files. You must enable this setting when the EAR file is assembled and the EJBDeploy is not run during packaging.

Default = false

Application name

Logical name for the application. The default name is the same as the Ear file. An application name must be unique within a cell.

Create MBeans for resources  

Specifies whether to create MBeans  for resources such as servlets or JSP files within an application when the application starts.

The default is to create MBeans

Override class reloading settings for Web and EJB modules 

Specifies whether the WebSphere Application Server run time detects changes to application classes when the application is running.

If this setting is enabled and if application classes are changed, then the application is stopped and restarted to reload updated classes.

The default is not to enable class reloading.

Reload interval in seconds

Specifies the number of seconds to scan the application's file system for updated files.

Process embedded configuration

Specifies whether the embedded configuration should be processed. An embedded configuration consists of files such as resource.xml and variables.xml. When selected or true, the embedded configuration is loaded to the application scope from the .ear file.

File Permission

  • Allows all files to be read but not written to.
  • Allows executables to execute.
  • Allows HTML and image files to be read by everyone..

Application Build ID

A string that identifies the build version of the application. Once set, it cannot be edited.

Allow dispatching includes to remote resources

Web modules included in this application are enabled as remote request dispatcher clients that can dispatch remote includes.

Default = true

 

Allow servicing includes from remote resources 

Web modules included in this application are enabled as remote request dispatcher servers that are resolved to service remote includes from another application. Default = true

Business level application name

Specifies whether the product creates a new business-level application with the enterprise application that you are installing or makes the enterprise application a composition unit of an existing business-level application.

Asynchronous Request Dispatch Type

Specifies whether Web modules can dispatch requests concurrently on separate threads.

Allow EJB reference targets to resolve automatically 

Specifies whether the product assigns default JNDI values for or automatically resolves incomplete EJB reference targets.

For this deployment, we will leave the majority of these values as default. Except we will override the EAR application name to be:

DefaultApplication

as opposed to

DefaultApplication.ear

Click on Next to move on to the Map modules to server page.

Map the application to the appropriate server. At this stage, we only have one application server profile; however, we can administer several application servers and manage multiple server nodes. For this application, we will see two resources contained in the application. An EJB and a WAR file. We want to ensure that both of these are mapped to the same server server1. Select both checkboxes and click Apply to ensure the application modules are bound to server1, as shown in the following screenshot:

WebSphere Application Server 7.0 Administration Guide

Accept defaults and click Next.

You will now be presented with a summary of the options chosen during the configuration of the deployment. Click Finish and the wizard will expand the uploaded EAR file into a temporary folder and override any files as required.

Up until now, all the work that has been done by the wizard has been in a temporary folder called wstemp, found at the root of the application server's profile. Here is an example of what that might look like:

<profile_root>wstemp/anonymous1231468782776/workspace/cells/
websphereNode01Cell/applications/DefaultApplication.ear

Once the EAR file has been deployed, a report will be given where you will be asked to save. This will store the EAR file to the installedApps folder, which is in the following location:

/<profile_root>/appsrv01/installedApps/websphereNode01Cell

The EAR file in the installedApps folder is expanded and is the runtime version of the application, meaning this is what WebSphere considers to be the actual application.

There is another important area known as the application registry and an EAR file will also exist there too, containing the actual EAR file which was uploaded. The applications registry is located at:

<profile_root>/config/cells/websphereNode01Cell/applications

Click Save to continue. The application has now been deployed.

Navigate to the Applications section of the administration console and click WebSphere enterprise applications and you will get a list of installed applications.

Starting and stopping your applications

In the WebSphere enterprise applications screen, we will see a list of applications which have been installed and their current state. Below is a table explaining the actions which can be performed against one or more selected applications.

Option

Description

Start

When an application is stopped you will see a WebSphere Application Server 7.0 Administration Guide icon

To start, select one or more application and click the Start button

Stop

When an application is started you will see a WebSphere Application Server 7.0 Administration Guide icon

To stop, select one or more applications and click the Stop button

Install

As part of deploying an application, you install application files on a server. Depending on EAR /WAR complexity, the deployment wizard will dynamically produce a guide of steps which require user input.

Uninstall

Select applications you wish to uninstall. It is recommended you stop applications first.

Update

To apply delta updates. Only the application code elements that have been changed in the application since last deployment are updated while the application remains running.

Rollout Update

If the application is deployed on one or more clusters spread across multiple nodes using this method reduces the amount of time that any single cluster member is unavailable for service.

Remove File

Deletes a file of the deployed application or module. Remove File deletes a file from the configuration repository and from the file system of all nodes where the file is installed.

Export

Allows the application to be exported as an Ear file. Can be used to backup an application version.

Export DDL

Exporting DDL (Table.ddl) files in the EJB modules of an application downloads the DDL files to a location of your choice, if there are not DDL files a message will be displayed.

Export File

Allows the exporting of  a specific file from an enterprise application or module.

We are going to start the default application. Select DefaultApplication and click on the Start action, as shown in the following screenshot:

WebSphere Application Server 7.0 Administration Guide

When an application has successfully started, you will a message similar to the one shown below:

WebSphere Application Server 7.0 Administration Guide

Now, DefaultApplication is started, we can use a web browser to navigate to the URL http://<host_name>:9080/snoop.

The following screen will load.

WebSphere Application Server 7.0 Administration Guide

The default application contains a very useful administration servlet.

The snoop servlet is an excellent tool to use in testing. Snoop reports on the following attributes:

  • Servlet context initialization parameters
  • URL invocation request parameters
  • Preferred client locale
  • Context path
  • User principal
  • Request headers and their values
  • Request parameter names and their values
  • HTTPS protocol information
  • Servlet request attributes and their values
  • HTTP session information
  • Session attributes and their values

>> Continue Reading Deploying your Applications on WebSphere Application Server 7.0 (Part 2)

WebSphere Application Server 7.0 Administration Guide Manage and administer your IBM WebSphere application server to create a reliable, secure, and scalable environment for running your applications with this book and eBook
Published: August 2009
eBook Price: $29.99
Book Price: $49.99
See more
Select your format and quantity:

About the Author :


Steve Robinson

Steve Robinson is an independent WebSphere specialist and consultant. He has been consulting in IT since 1997 and has been involved in client projects around the globe; many of which are for fortune 500 companies.

Steve started out originally as a consultant in the IBM Lotus Notes/Domino product suite, where he excelled in middleware integration technologies to ensure homogenous environments could exist in the new heterogeneous world. Having worked for many different industries, Steve has had a plethora of experience in the integration of most technologies across many different systems and cultures. He is also an accomplished programmer in including C, Java, and the Microsoft .NET development tools.

Steve has gleaned many insights due to the amount of large enterprise projects he has been involved with and his passion for documentation and process improvement is recognized by all those he works with.

Steve is married and lives with his family in England. He spends his time either writing, or researching new products and technologies for client projects along with investigating new ways to automate process where possible.

Steve is also known for his contribution to the WebSphere Internet community through one of his many top-ranking WebSphere knowledge portals: http://www.webspheretools.com.

Books From Packt

Flex 3 with Java
Flex 3 with Java

Spring Web Flow 2 Web Development
Spring Web Flow 2 Web Development

Seam 2.x Web Development
Seam 2.x Web Development

JBoss Tools 3 Developers Guide
JBoss Tools 3 Developers Guide

Pentaho Reporting 3.5 for Java Developers
Pentaho Reporting 3.5 for Java Developers

Oracle SOA Suite Developer's Guide
Oracle SOA Suite Developer's Guide

Liferay Portal 5.2 Systems Development
Liferay Portal 5.2 Systems Development

Drools JBoss Rules 5.0 Developer's Guide
Drools JBoss Rules 5.0 Developer's Guide

 

Your rating: None Average: 4.6 (14 votes)
Hi by
How to deploy an application using scripting?
Useful info by
Thanks
good, thanks. by
good, thanks.
Nice explanation step by step by
Nice explanation step by step [:)]
Excellent documentation by
Very good, and precisely to the point. Thanks

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
B
z
1
s
W
K
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software