Anda di halaman 1dari 14

Table of Contents

Chapter 25. WebSphere Rapid Deployment (WRD)................................................................. 1


Invoking WRD.................................................................................................................................................................................................................................. 1
Deploying Applications with WRD................................................................................................................................................................................................. 2

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
25
WebSphere Rapid Deployment
(WRD)

W ebSphere Rapid Deployment (WRD), a feature new to WebSphere Application


Server in Version 6, is designed to simplify the development and deployment
of WebSphere applications. WRD is a collection of Eclipse plug-ins that can be inte-
grated within development tools or run in a headless mode, without headers, from a
user file system. WRD is currently integrated in Application Server Toolkit, Rational
Application Developer, and Rational Web Developer. Initially, WRDs features are sup-
ported only in headless mode.

During development, you use annotation-based programming with WRD. The developer
adds into the application source code metadata tags used to generate artifacts that the
code requires, thus reducing the number of artifacts the developer needs to create. The
application is then packaged into an Enhanced EAR file that contains the J2EE EAR file
along with deployment information, application resources, and properties (e.g., environ-
ment variables, JAAS authentication entries, shared libraries, class loader settings, and
JDBC resources). During installation, WRD uses this information to create the necessary
resources. Moving an application from one server to another also moves the resources.
WRD automates the installation of applications and modules onto a running application
server by monitoring the workspace for changes and then driving the deployment
process.

Invoking WRD
You can use the rapid deployment launch tool (wrd.bat or wrd.sh) to specify that you
want WRD to start listening for application artifacts that are dropped into a monitored
project. The wrd command runs in a nongraphical mode using a command-line interface:

731

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
CHAPTER 25: WebSphere Rapid Deployment (WRD)

On Windows, enter wrd.bat [<optional parameters>].


On Unix, enter wrd.sh [<optional parameters>].
The command supports the following optional parameters:
monitor Enables console feedback from the rapid deployment tool.
project <project_name> Specifies the name of the rapid deployment
project you want to target to run in batch mode. You use this parameter only in
conjunction with the batch parameter.

Licensed by
batch Enables batch mode on a specified target project. Batch mode runs a
full build on a rapid deployment workspace and then shuts down the process.
usage Displays the optional parameters for the command.

Mahaboob Hussain
Deploying Applications with WRD
You can configure WRD to automatically install (or uninstall) J2EE applications (EAR

3845101
files) that are deposited in its workspace or to construct and deploy a J2EE-compliant
application from artifacts or modules you create or drop into a freeform project. In this
section, we review the steps for both of these alternatives.

Automatically Install an EAR


To set up WRD to automatically install J2EE applications packaged as EARs, the first
thing you should do is open a command prompt window. Then, create a source directory
into which youll drop the EAR to be deployed and define an environment variable
called WORKSPACE to point to that directory. For this example, well use the following
values for the source directory and environment variable:
C:\Program Files\IBM\WebSphere\AppServer\bin>md c:\WRD
C:\Program Files\IBM\WebSphere\AppServer\bin>set WORKSPACE=c:\WRD

Next, you need to configure the workspace you just created. You use the rapid deploy-
ment configuration command, wrd-config, to do so. For this example, well use the
AutoAppInstall style of deployment. Listing 25-1 shows the command and its execution.
Accept the default parameter configuration settings by pressing the Enter key.

Listing 25-1
Configuring the WRD workspace for AutoAppInstall mode

C:\Program Files\IBM\WebSphere\AppServer\bin>wrd-config -project AutoInstall


-style autoappinstall
Launching WebSphere Rapid Deployment configuration. Please wait...

732

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
Deploying Applications with WRD

Starting Workbench...

Starting up the workbench.

---------------------------------------------------------
Parameter Configuration Settings
---------------------------------------------------------
Press ENTER to accept defaults
The * symbol denotes required input

Enter the server name* ( server1 ) :


Enter the server JMX host name* ( localhost ) :
Enter the server JMX port number* ( 8880 ) :
Enter your server username ( ) :
Enter your server password ( ) :

WebSphere Rapid Deployment configuration completed.


Shutting down the workbench.

Next, start the WRD utility. Well start the tool in monitor mode to have all messages
sent to the console window. Listing 25-2 shows the command execution.

Listing 25-2
Starting WRD in monitor mode

C:\Program Files\IBM\WebSphere\AppServer\bin>wrd -monitor


Launching WebSphere Rapid Deployment. Please wait...
Starting Workbench...

Starting up the workbench.


WebSphere Rapid Deployment ready for e-business...

Type q, quit, or exit to shut down WebSphere Rapid Deployment processes.

Now, well use the WebSphere Bank application (which you worked with in previous chap-
ters) to illustrate how the rapid deployment tool works. Copy the WebSphereBank.ear file to
the C:\WRD\AutoInstall directory. As soon as you do that, the WRD utility will detect the
EAR and begin to install it. Listing 25-3 shows the installations progress. You can verify
that the WebSphere Bank application has indeed been installed by viewing it in the admin
console. (Select Applications|Enterprise Applications in the navigation tree to do so.)

Listing 25-3
Command-line notifications for WebSphere Bank installation

[04:19:16 PM] !INSTALL_EAR_FILE WebSphereBank.ear!


[04:19:16 PM] Publishing WebSphereBank to server_510658053

733

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
CHAPTER 25: WebSphere Rapid Deployment (WRD)

[04:19:19 PM] Updating Application. WebSphereBank


[04:19:55 PM] Installation Completed Successfully:
[04:19:55 PM] Starting Application: WebSphereBank
[04:19:55 PM] Application Started Successfully: WebSphereBank

Automatically Remove an EAR


If you delete the EAR, WRD will remove the application. Figure 25-1 illustrates the
deletion of the EAR file for the WebSphere Bank application.

Figure 25-1: Deleting the WebSphereBank EAR

To see WRD removing the application, check the command prompt (Listing 25-4).

Listing 25-4
Command-line notifications for WebSphere Bank removal

[04:41:23 PM] !DELETE_EAR_WRAPPER WebSphereBank.ear!


[04:41:23 PM] Uninstalling WebSphereBank:server_510658053
[04:41:50 PM] Application Uninstalled: WebSphereBank

734

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
Deploying Applications with WRD

Automatically Deploy a Freeform Application


The WRD tools freeform configuration lets you create or drop your J2EE artifacts or
modules into a freeform project. J2EE artifacts include source code, annotated source
code or class files of servlets, Java Server Page (JSP) files, static Web content files,
enterprise beans, and so on. WRD takes the artifacts you drop into the freeform project
directory, automatically places them into the appropriate J2EE project structure, gener-
ates any additional required artifacts (e.g., deployment descriptors) to create a fully
compliant J2EE application, and then deploys the application.

To deploy an application using this method, you first need to configure the freeform
project. Listing 25-5 shows the wrd-config command being executed to set the required
configuration parameters.

Listing 25-5
Configuring a WRD freeform project

C:\Program Files\IBM\WebSphere\AppServer\bin>wrd-config -project Hello -


style freeform
Launching WebSphere Rapid Deployment configuration. Please wait...
Starting Workbench...

Starting up the workbench.

---------------------------------------------------------
Parameter Configuration Settings
---------------------------------------------------------
Press ENTER to accept defaults
The * symbol denotes required input

Enter the server name* ( server1 ) :


Enter the server JMX host name* ( localhost ) :
Enter the server JMX port number* ( 8880 ) :
Enter a path for containing the exported EAR ( ) :
Enter your server username ( ) :
Enter your server password ( ) :

WebSphere Rapid Deployment configuration completed.


Shutting down the workbench.

Next, start WRD as before, by issuing the wrd monitor command.

At this point, lets assume that a Java source file called HelloWorld.java exists in the
directory C:\temp\HW\com\orc\helloworld. Listing 25-6 shows the HelloWorld.java
source file.

735

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
CHAPTER 25: WebSphere Rapid Deployment (WRD)

Listing 25-6
HelloWorld.java source file

package com.orc.helloworld;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @version 1.0
* @author O. Cline
*/
public class HelloWorld extends HttpServlet {

/**
* @see javax.servlet.GenericServlet#void ()
*/
public void destroy() {

super.destroy();
}

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServ-
letRequest, javax.servlet.http.HttpServletResponse)
*/
public void doDelete(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.
HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

resp.setContentType(text/html);
PrintWriter out = resp.getWriter();

out.print(Hello World);

out.close();
}

736

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
Deploying Applications with WRD

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.
HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req, resp);

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.
HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doPut(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

/**
* @see javax.servlet.GenericServlet#java.lang.String ()
*/
public String getServletInfo() {

return super.getServletInfo();

/**
* @see javax.servlet.GenericServlet#void ()
*/
public void init() throws ServletException {

super.init();

/**
* @see java.lang.Object#java.lang.String ()
*/
public String toString() {

return super.toString();

Copy this file and its package directories to the WRD freeform project directory. Figure
25-2 shows the WRD directory after youve completed this step.

737

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
CHAPTER 25: WebSphere Rapid Deployment (WRD)

Figure 25-2: Freeform project directory after source code copied

Once youve copied the source code to the freeform project, WRD will detect its pres-
ence and then build and deploy a J2EE application. Listing 25-7 shows the command-
line notifications youll see as WRD takes the steps required to create and deploy the
HelloWorld application.

Listing 25-7
WRD notification of successful application creation and deployment

[05:13:17 PM] [/Hello/com/orc/helloworld/HelloWorld.java] Added


[05:13:23 PM] [/Hello/bin/com/orc/helloworld/HelloWorld.class] copied to
project [HelloWeb]
[05:13:23 PM] [/Hello/com/orc/helloworld/HelloWorld.java] Added
[05:13:24 PM] Servlet added to web.xml: HelloWorld
[05:13:24 PM] Servlet mapping added. URL is: [HelloWeb/HelloWorld]
[05:13:24 PM] Publishing IBMUTC to server_510658053
[05:13:24 PM] Publish requested for this change.
[05:13:26 PM] Updating Application. IBMUTC
[05:13:38 PM] Installation Completed Successfully:
[05:13:38 PM] Starting Application: IBMUTC
[05:13:38 PM] Application Started Successfully: IBMUTC
[05:13:38 PM] J2EE deployment started.
[05:13:39 PM] J2EE deployment completed.
[05:13:39 PM] Publishing HelloApp to server_510658053
[05:13:39 PM] Installing New Application: HelloApp
[05:13:42 PM] Installation Completed Successfully:
[05:13:42 PM] Starting Application: HelloApp
[05:13:43 PM] Application Started Successfully: HelloApp

738

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
Deploying Applications with WRD

Now, you can test your application. Figure 25-3 shows a successful test of HelloWorld.

Figure 25-3: Verifying that the HelloWorld application is deployed

Next, lets see how WRD reacts when you modify the source file. Edit the
HelloWorld.java file directly inside the freeform project by changing the string output by
the application from Hello World to Hello World AGAIN. Listing 25-8 shows the
modified section of source code.

Listing 25-8
Modifying the HelloWorld output string

.
.
.
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

739

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
CHAPTER 25: WebSphere Rapid Deployment (WRD)

resp.setContentType(text/html);
PrintWriter out = resp.getWriter();

out.print(Hello World AGAIN);

out.close();

.
.
.

As soon as you save the HelloWorld.java file, WRD will detect that youve done so and
update the application. Listing 25-9 shows the command-line confirmation youll
receive.

Listing 25-9
Command-line notifications for updated HelloWorld application

[05:17:47 PM] [/Hello/com/orc/helloworld/HelloWorld.java] Modified


[05:17:48 PM] [/Hello/bin/com/orc/helloworld/HelloWorld.class] copied to
project [HelloWeb]
[05:17:48 PM] Publish requested for this change.
[05:17:48 PM] J2EE deployment started.
[05:17:48 PM] J2EE deployment completed.
[05:17:48 PM] [/Hello/com/orc/helloworld/HelloWorld.java] Modified
[05:17:48 PM] Publishing HelloApp to server_510658053

As a last step, verify that your change was deployed successfully. Figure 25-4 shows the
output you can expect.

740

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
Deploying Applications with WRD

Figure 25-4: Verifying that the change to HelloWorld was successful

741

Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
Chapter 25. WebSphere Rapid Deployment (WRD). WebSphere Application Server: Step by Step, ISBN: 9781583470619
Prepared for hussain.mahaboob@tcs.com, Mahaboob Hussain
Copyright 2006 MC Press Online, LP.. This download file is made available for personal use only and is subject to the Terms of Service. Any other use requires prior written consent
from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.

Anda mungkin juga menyukai