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)
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)
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.
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
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...
---------------------------------------------------------
Parameter Configuration Settings
---------------------------------------------------------
Press ENTER to accept defaults
The * symbol denotes required input
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
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
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)
To see WRD removing the application, check the command prompt (Listing 25-4).
Listing 25-4
Command-line notifications for WebSphere Bank removal
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
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
---------------------------------------------------------
Parameter Configuration Settings
---------------------------------------------------------
Press ENTER to accept defaults
The * symbol denotes required input
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)
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
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.
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.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
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
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.