You are on page 1of 32

IBM Software An IBM Proof of Technology

WebSphere

Lab 2: Deploy a WebSphere


Application in CLI
IBM Software

Contents
LAB 2: DEPLOY A WEBSPHERE APPLICATION IN CLI ............................................................................................................. 3
1. BUSINESS SCENARIO ...................................................................................................................................... 3
2. OBJECTIVE .................................................................................................................................................... 6
3. PREREQUISITES ............................................................................................................................................. 6
4. WHAT IS ALREADY COMPLETED ....................................................................................................................... 6
5. LAB TASKS .................................................................................................................................................... 7
6. DEPLOY AND TEST DAYTRADER APPLICATION ................................................................................................... 7
APPENDIX A. NOTICES .......................................................................................................................................................... 26
APPENDIX B. TRADEMARKS AND COPYRIGHTS ............................................................................................................... 28

Page 2 Move WebSphere Application to Cloud


IBM Software

Lab 2: Deploy a WebSphere Application in CLI


This lab will show how to deploy a WebSphere Application in command line interface (CLI) using
wsadmin scripts. In this lab, we will deploy the DayTrader application, a web application emulating an
online stock trading system, to the WebSphere Application Server using a wsadmin script.

Please refer to the following table for file and resource location references for different operating systems.

Location Ref. OS Absolute Path

Windows

{USBKEYHOME} Linux

Mac OSX

Windows

{LABHOME} Linux /home/ibmdemo/Student

Mac OSX

1. Business Scenario
A Customer has developed a WebSphere applications, DayTrader, and now they want to deploy this
application to their WebSphere Application server environment using wasadmin scripts and CLI.

DayTrader is a web application emulating an online stock trading system. Users can log in to view their
accounts and stock portfolio. Using the Quotes/Trade feature, a user can buy or sell stock shares out of
their portfolio. As an end-to-end Java™ Enterprise Edition (J2EE) web application, DayTrader is
composed of several Java classes, Java Servlets, Java Server Pages, Web Services and Enterprise
Java Beans (EJB). As shown in the Architecture Overview diagram below, the presentation layer of this
application is based on Java Servlets and Java Server Pages, whereas the back-end business logic uses
Java database connectivity (JDBC), Java Message Service (JMS), EJB and Message Bean techniques.

Appendix Page 3
IBM Software

In this lab, the Trade Database is hosted on a DB2® database server and is accessed via JDBC from the
application server.

Two screen-shots from the application can be seen below. Once a user logs-in, they can browse to the
Account, Portfolio, and Quotes/Trade sections to view their stock holdings or conduct stock trades.

Page 4 Move WebSphere Application to Cloud


IBM Software

Appendix Page 5
IBM Software

2. Objective
The objectives of this lab are:

 Demonstrate how easy it is to deploy a WebSphere application using wasadmin script and CLI;
 Allow students to get familiar with the wasadmin script and its usage.

3. Prerequisites
The following prerequisites are required for this lab:
 WAS9 Admin PoT Lab 1 is completed
 Experience with WebSphere Application Server and its admin console
 Experience with the WebSphere Application deployment process
 Familiarity with basic Linux commands

The following symbols appear in this document at places where additional guidance is available.

Icon Purpose Explanation

This symbol calls attention to a particular step or command.


Important! For example, it might alert you to type a command carefully
because it is case sensitive.

This symbol indicates information that might not be


Information
necessary to complete a step, but is helpful or good to know.

Trouble- This symbol indicates that you can fix a specific problem by
shooting completing the associated troubleshooting information.

4. What is Already Completed


A Ubuntu Linux VM has been provided for this lab.

The login credentials for the VM are:

User ID: ibmdemo

Password: passw0rd

Note: the password is the same Ubuntu Terminal sudo password you are going to use in the Lab.

Page 6 Move WebSphere Application to Cloud


IBM Software

On the VM, the following Lab components are ready for use:

 The WebSphere Application Server runtime is setup and configured. The installation location of
the WebSphere Application Server is at /opt/IBM/WebSphere
 The DB2 Server is installed and ready to use. The installation location of the DB2 Server is at
/opt/ibm/db2/V10.5
 wsadmin deployment script package, including the DayTrader application ear file and associated
database DDLs, are available in /home/ibmdemo/Student/DayTrader3Install folder

5. Lab Tasks
To achieve the objectives of the Lab, the following tasks must be completed:

 Deploy and test the DayTrader application in the local workstation


o Create a DB2 database named TradeDB for the DayTrader application
o Deploy the DayTrader application to the WebSphere Application Server on the local
workstation
o Test the deployed DayTrader application

6. Deploy and Test DayTrader Application

6.1 Start the DB2 Database

The DayTrader application requires a database. In this Lab, we are going to use a DB2 database to
support the application. A DB2 database called TRAEDB is already created for this lab. Following the
steps highlighted below to start the DB2 database, if it is not started yet.

__1. DB2 is not running as a service, so you will need to start DB2 by opening a Terminal window and
entering “su - db2inst1” and enter the password as db2inst1-pwd which will change you from
the user ibmdemo to db2inst1
__2. Enter the command db2start as and wait for the message “SQL1063N DB2START processing was
successful” as shown below.

__3. Run command db2 list database directory to view the databases

Appendix Page 7
IBM Software

__4. Enter exit to change back to the ibmdemo user.

6.2 Start WebSphere Application Server

The DayTrader application is running on a WebSphere Application Server environment. A WebSphere


Application Server instance called server1 is provided in the Ubuntu workstation. The installation
location of the WebSphere Application Server is at /opt/IBM/WebSphere. Follow the steps below to
start the server1.

__5. In the Ubuntu terminal console, issue WAS startServer command to start server1

sudo /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startServer.sh server1

The server1 will take a few moments to start.

__6. Wait until you see the message

ADMU3000I: Server server1 open for e-business; process id is xxx

At this time, the steps to start the WebSphere Application Server server1 have been completed.

6.3 Deploy the DayTrader Application

Now the WebSphere Application server has been started, a WAS wsadmin script will be used to deploy
the DayTrader application to it.

Page 8 Move WebSphere Application to Cloud


IBM Software

Note: The deployment scripts MUST be run as the superuser sudo.

__1. From the Ubuntu terminal window, navigate to the DayTrader deployment package folder under
/home/ibmdemo/Student directory with command:

cd /home/ibmdemo/Student/DayTrader3Install/DayTrader3-EE6

__2. List the contents of the folder by entering the command

ls -l

Note: the command above is in lower case.

The deployment package files can be found here.

Note: All of these files and folders are from the standard DayTrader application deployment
package except five scripts created for this Lab. Since we have a single WAS Server
environment, we are going to use the daytrader_singleServer.py script to deploy the DayTrader
application.

__3. Use the file edit tool gedit to open the daytrader_singleServer.py script and review its contents

sudo gedit daytrader_singleServer.py

Appendix Page 9
IBM Software

__4. Run deployment script to deploy the DayTrader application to the server1:

sudo /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -f
daytrader_singleServer.py all

Follow the on screen prompts, and provide the responses illustrated below

When prompted, enter the WAS admin user name and password as:

Username: wsadmin

Password: wsadmin

Page 10 Move WebSphere Application to Cloud


IBM Software

__5. Enter true as the value for the Global security enabled question

__6. Accept the default server name server1 and press Enter

__7. Accept the default JDBC provider type and press Enter

Appendix Page 11
IBM Software

__8. Accept the default EJB deployment target and press Enter

__9. Enter the location of the JDBC driver files as:

/opt/ibm/db2/V10.5/java/db2jcc.jar;/opt/ibm/db2/V10.5/java/db2jcc_license_cu.jar

__10. Accept the default database name.

Page 12 Move WebSphere Application to Cloud


IBM Software

__11. Accept the default database name.

__12. Accept the default database port

__13. Enter the database username as: db2inst1

__14. Enter the database password as: db2inst1-pwd

__15. Accept the default value for Use file store JMS Provider and press Enter

__16. Accept the default value for ME file store location and press Enter

__17. Enter wsadmin as administrative username

Appendix Page 13
IBM Software

__18. Enter wsadmin as administrative password

__18. The script will start to deploy the DayTrader application to your WAS server. When the
deployment is finished, the message “DayTrader Installation Completed!!!” will be displayed.

__19. After the deployment, server1 needs to be restarted. Issue a serverStop command as:

sudo /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/stopServer.sh server1

If login information is requested, enter the WAS Admin credentials and click OK.

User Id: wsadmin

Password: wsadmin

Page 14 Move WebSphere Application to Cloud


IBM Software

After the server1 stopped, issue the command below to re-start it.

sudo /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startServer.sh server1

The DayTrader application deployment task has been completed. Once the server starts,
continue to the next section.

6.4 Change the JPA Provider Level for WAS V9

Since the DayTrader application was developed with JPA 2.0 and the default JPA provider (EclipseLink)
in WAS V9 is JPA 2.1, in this section you will query and then change the JPA level for the WAS V9
server to JPA 2.0 using the wsadmin commands.

__1. In the Linux Terminal Window, issue the following commands to enter an interactive wsadmin
session

sudo /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh

enter the username and password as: wsadmin/wsadmin

__2. After a few seconds the wsadmin command prompt will be displayed

__3. Enter the following wsadmin command to query the current JPA level for the tWAS V9 server.
The result will be 2.1

$AdminTask showJPASpecLevel {-node ubuntuNode01 -server server1}

__4. Enter the following wsadmin command to change the JPA level for the tWAS V9 server to 2.0

$AdminTask modifyJPASpecLevel {-node ubuntuNode01 -server server1 -specLevel 2.0}

Appendix Page 15
IBM Software

__5. Enter the following wsadmin command to save the changes to the master configuration

$AdminConfig save

__6. Enter quit to end the wasadmin session.

__7. Issue the following commands to stop and the start the server1

sudo /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/stopServer.sh server1

sudo /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startServer.sh server1

6.5 Test and Verify the DayTrader Application on the Local workstation

__1. Return to Firefox web browser. If the WAS Admin Console page was not closed before, close it
now, and click the WAS Console bookmark on the Firefox Bookmark Bar to re-launch the WAS
Admin Console.

__2. Log in WAS Admin Console using the following credentials

user: wsadmin

password: wsadmin

__3. In the Admin Console, click Resources->JDBC->Data sources, to view the data sources we
just created for the DayTrader application

Page 16 Move WebSphere Application to Cloud


IBM Software

__4. To verify the data source setup, check the boxes next to the TradeDataSource and
NoTxtTradeDataSource,, and click the Test connection button. A connection successful
message will be displayed.

Appendix Page 17
IBM Software

__5. Now select Applications->Application Types-> WebSphere Enterprise Applications from the
Admin Console navigation menu on the left. The DayTrader application (DayTrader3-EE6)
should appear on the list. DayTrader3 should be started.

Page 18 Move WebSphere Application to Cloud


IBM Software

__6. To access the DayTrader application, open a Firefox web browser window and enter the
application url http://localhost:9080/daytrader/.

__7. On the DayTrader application Home Page, click the Configuration Tab to go to the application
Configuration Utilities page

__8. On the Configuration Utilities page, first click the (Re)-create DayTrader Database Tables and
Indexes link to create the database tables.

Appendix Page 19
IBM Software

right

The utility will create the database tables and show the results on a different web browser window
as follows

__9. Go back to the DayTrader Window and go to the Configuration Utilities page, and click the
Configure DayTrader run-time parameters to set the maximum number of users and quotes to
populate into the database tables.

Page 20 Move WebSphere Application to Cloud


IBM Software

The utility will allow you to specify the number of DayTrader users and Quotes to populate into
the DB2 database. The default is 15,000 users and 10,000 quotes, which is far more than
needed for the lab.

__a. From the configuration page, scroll down to the Miscellaneous Settings section

__b. Change the DayTrader Max Users to 100

__c. Change the Trade Max Quotes to 100

__d. Click on the Update Config Button located on the lower right corner of the configuration
page. This will save the configuration settings in the database.

Appendix Page 21
IBM Software

__e. Verify the configuration has been successfully updated

__10. Go back to the DayTrader Window and go to the Configuration Utilities page, and click the
(Re)-populate DayTrader Database to add data to the database tables

The utility will populate the database table and show the results on a different web browser
window as follows

Wait for message “DayTrader Database Built – 100users created”, as shown below to make
sure the process has finished.

Page 22 Move WebSphere Application to Cloud


IBM Software

Once the database is populated, it is ready for use.

__11. Go back to the DayTrader window, click the Trading & Portfolios Tab, and see the DayTrader
Login page. Accept the default Username and Password and click the Log in button.

__13. Once logged in, click the Home Link. Access your account info and trade stocks in the
application.

__14. Test and verify the application by navigating to Account, Portfolio and Quotes/Trade pages
and conduct some stock buy/sell operations.

Appendix Page 23
IBM Software

6.6 Update the web server plug-ins

Now you have a running application, you need to update the web server plug-ins next so you can access
the application through the web server

__1. From the WAS Admin console, click Environment > Update global web server plug-in
configuration and click OK to update the plug-in file.

you will see the message below indicating the plug-in file is updated.

__2. The updated plugin-cfg.xml is stored at


/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells directory, you need to copy
and paste it to /opt/IBM/WebSphere/Plugins/config/webserver1 directory with command:

sudo cp /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells/plugin-cfg.xml
/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-cfg.xml

when prompted, enter the sudo password as passw0rd.

__3. Now you can access the DayTrader application through the web server with url
http://localhost/daytrader

Congratulations, the DayTrader application has been successfully deployed to the WebSphere
Application Server.

===== END OF LAB =====

Page 24 Move WebSphere Application to Cloud


IBM Software

Appendix Page 25
IBM Software

Appendix A. Notices
This information was developed for products and services offered in the U.S.A.

IBM may not offer the products, services, or features discussed in this document in other countries.
Consult your local IBM representative for information on the products and services currently available in
your area. Any reference to an IBM product, program, or service is not intended to state or imply that
only that IBM product, program, or service may be used. Any functionally equivalent product, program, or
service that does not infringe any IBM intellectual property right may be used instead. However, it is the
user's responsibility to evaluate and verify the operation of any non-IBM product, program, or service.

IBM may have patents or pending patent applications covering subject matter described in this document.
The furnishing of this document does not grant you any license to these patents. You can send license
inquiries, in writing, to:

IBM Director of Licensing


IBM Corporation
North Castle Drive
Armonk, NY 10504-1785
U.S.A.

For license inquiries regarding double-byte (DBCS) information, contact the IBM Intellectual Property
Department in your country or send inquiries, in writing, to:

IBM World Trade Asia Corporation


Licensing
2-31 Roppongi 3-chome, Minato-ku
Tokyo 106-0032, Japan

The following paragraph does not apply to the United Kingdom or any other country where such
provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES
CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some
states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this
statement may not apply to you.

This information could include technical inaccuracies or typographical errors. Changes are periodically
made to the information herein; these changes will be incorporated in new editions of the publication.
IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this
publication at any time without notice.

Any references in this information to non-IBM Web sites are provided for convenience only and do not in
any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part
of the materials for this IBM product and use of those Web sites is at your own risk.

IBM may use or distribute any of the information you supply in any way it believes appropriate without
incurring any obligation to you.

Any performance data contained herein was determined in a controlled environment. Therefore, the
results obtained in other operating environments may vary significantly. Some measurements may have

Page 26 Move WebSphere Application to Cloud


IBM Software

been made on development-level systems and there is no guarantee that these measurements will be
the same on generally available systems. Furthermore, some measurements may have been estimated
through extrapolation. Actual results may vary. Users of this document should verify the applicable data
for their specific environment.

Information concerning non-IBM products was obtained from the suppliers of those products, their
published announcements or other publicly available sources. IBM has not tested those products and
cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM
products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of
those products.

All statements regarding IBM's future direction and intent are subject to change or withdrawal without
notice, and represent goals and objectives only.

This information contains examples of data and reports used in daily business operations. To illustrate
them as completely as possible, the examples include the names of individuals, companies, brands, and
products. All of these names are fictitious and any similarity to the names and addresses used by an
actual business enterprise is entirely coincidental. All references to fictitious companies or individuals are
used for illustration purposes only.

COPYRIGHT LICENSE:

This information contains sample application programs in source language, which illustrate programming
techniques on various operating platforms. You may copy, modify, and distribute these sample programs
in any form without payment to IBM, for the purposes of developing, using, marketing or distributing
application programs conforming to the application programming interface for the operating platform for
which the sample programs are written. These examples have not been thoroughly tested under all
conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or function of these
programs.

Appendix Page 27
IBM Software

Appendix B. Trademarks and copyrights


The following terms are trademarks of International Business Machines Corporation in the United States,
other countries, or both:

IBM AIX CICS ClearCase ClearQuest Cloudscape

Cube Views DB2 developerWorks DRDA IMS IMS/ESA

Informix Lotus Lotus Workflow MQSeries OmniFind

Rational Redbooks Red Brick RequisitePro System i

System z Tivoli WebSphere Workplace System p

Adobe, the Adobe logo, PostScript, and the PostScript logo are either registered trademarks or
trademarks of Adobe Systems Incorporated in the United States, and/or other countries.

IT Infrastructure Library is a registered trademark of the Central Computer and Telecommunications


Agency which is now part of the Office of Government Commerce.

Intel, Intel logo, Intel Inside, Intel Inside logo, Intel Centrino, Intel Centrino logo, Celeron, Intel Xeon, Intel
SpeedStep, Itanium, and Pentium are trademarks or registered trademarks of Intel Corporation or its
subsidiaries in the United States and other countries.

Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.

Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the
United States, other countries, or both.

ITIL is a registered trademark, and a registered community trademark of The Minister for the Cabinet
Office, and is registered in the U.S. Patent and Trademark Office.

UNIX is a registered trademark of The Open Group in the United States and other countries.

Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or
its affiliates.

Cell Broadband Engine is a trademark of Sony Computer Entertainment, Inc. in the United States, other
countries, or both and is used under license therefrom.

Linear Tape-Open, LTO, the LTO Logo, Ultrium, and the Ultrium logo are trademarks of HP, IBM Corp.
and Quantum in the U.S. and other countries.

Page 28 Move WebSphere Application to Cloud


NOTES
NOTES
© Copyright IBM Corporation 2016.

The information contained in these materials is provided for


informational purposes only, and is provided AS IS without warranty
of any kind, express or implied. IBM shall not be responsible for any
damages arising out of the use of, or otherwise related to, these
materials. Nothing contained in these materials is intended to, nor
shall have the effect of, creating any warranties or representations
from IBM or its suppliers or licensors, or altering the terms and
conditions of the applicable license agreement governing the use of
IBM software. References in these materials to IBM products,
programs, or services do not imply that they will be available in all
countries in which IBM operates. This information is based on
current IBM product plans and strategy, which are subject to change
by IBM without notice. Product release dates and/or capabilities
referenced in these materials may change at any time at IBM’s sole
discretion based on market opportunities or other factors, and are not
intended to be a commitment to future product or feature availability
in any way.

IBM, the IBM logo and ibm.com are trademarks of International


Business Machines Corp., registered in many jurisdictions worldwide.
Other product and service names might be trademarks of IBM or
other companies. A current list of IBM trademarks is available on the
Web at “Copyright and trademark information” at
www.ibm.com/legal/copytrade.shtml.

You might also like