3 Deploying Enterprise Java Web
application to IBM WebSphere
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
Chapter 3 - Deploying Enterprise Java Web
Application to IBM WebSphere
DB Visual ARCHITECT (DB-VA) provides different kinds of templates for users to generate Java code. The template will
optimize the configuration of generated Java code and select jar files for different application servers or standalone Java
application. In this chapter, we will deploy enterprise Java web application to IBM WebSphere. If the application server
supports datasource, you can also configure DB-VA to use datasource connection to connect the database on the server.
In this chapter:
• Introduction
• Preparing to Deploy to WebSphere
• Deploying Web Application to WebSphere
• Configuring Datasource on WebSphere
• Configuring Datasource Connection on DB-VA
Introduction
This document is based on the Programmer's Guide for Java - Chapter 3 Developing Java Enterprise Web Application example
to demonstrate the deployment step on the WebSphere Server. The Example of Programmer's Guide for java - Chapter 3 is
deployed on the JBoss Server, we need to modify some configuration before deploy on the WebSphere Server. Finally, we will
configure the web application to use the datasource connection provide by WebSphere server to connect to database.
Preparing to Deploy to WebSphere
Suppose you have downloaded the example of the Programmer's Guide for Java - Chapter 3 Developing Java Enterprise Web
Application. You need to change the template of generated code before deploy on the WebSphere Server.
1. From the menu bar, select Tools > Object Relational Mapping (ORM) > Generate Code ... to open Database Code
Generation dialog box.
Figure 3.1 - To generate code
3-2
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
2. Change Deploy To option from JBoss Application Server to Generic Application Server.
Figure 3.2 - Deploy directory
DB-VA helps you to select the corresponding Optional Jar files and set datasource options.
Figure 3.3 - Select Optional Jar
3. Click OK to regenerate code.
Copy the [Link]\src\ormmapping folder to [Link]\classes folder to make sure the
configuration files are also updated.
Deploying Web Application to WebSphere
Now the [Link] is updated and generated in the JBoss Server deploy folder.
1. Open the command prompt to the [Link] folder in the JBoss deploy folder.
2. Execute jar to create a war file in command prompt.
The command to create a war file:
jar - cvf [Link] .
The [Link] file is created inside the [Link] folder
Figure 3.4 - The war file
3-3
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
3. Startup WebSphere Application Server 6. Start menu > All Program > IBM WebSphere > Application Server v6
> Profiles > AppSrv01 > Start the server.
Figure 3.5 - Start the Server
4. Go to Administration Console ([Link] to login (note that the port number for some
WebSphere users may not be 9061, so replace it with the correct one in such case).
Figure 3.6 - Login page
5. Select Applications > Install New Application to install the [Link] file
Figure 3.7 - Install New Application
6. Select the War file and fill in the Context Root (schoolsystem)
Figure 3.8 - Select the file
7. Click Next to finish the installation.
3-4
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
8. Click Save to Master Configuration and click Save in this page to apply all changes.
Figure 3.9 - the successful deploy message
9. Start the new deploy SchoolProject Web Application. Select Applications > Enterprise Application.
Figure 3.10 - Select Enterprises Application
10. Select schoolsystem_war and click the Start button to startup the Web Application on the server.
Figure 3.11 - Select the Web Application
3-5
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
11. Go to ([Link] to confirm the web application is running
Figure 3.12 - The index page
Configuring Datasource on WebSphere
The WebSphere server can provide a datasource for application to share the JDBC connection within the server. The following
steps teach you how to configure datasource on WebSphere server. We will configure the MySQL datasource on WebSphere
server as an example.
1. Go to Administration Console ([Link] ) to login.
Figure 3.13 - The Administrator Console
2. Select Resources > JDBC Providers
Figure 3.14 -
3-6
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
3. Click New button to create MySQL JDBC provider
Figure 3.15 - the JDBC Provider
4. In Choose a type of JDBC provider, set all options to User-defined
Figure 3.16 - Create a new JDBC provider
5. Fill in general properties and click Apply.
Name MySQL JDBC provider
C:\DevelopApps\jboss-4.0.3SP1\server\default\deploy\[Link]\WEB-
Classpath
INF\lib\[Link]
Implementation class
[Link]
name
3-7
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
Figure 3.17 - The General Properties
6. Select the Additional Properties > Data sources on the right hand side.
Figure 3.18 - The Additional properties
7. Click the New button to create new MySQL Data source.
Figure 3.19 - New a Data source
3-8
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
8. Fill in new MySQL Data source information and click Apply
Name MySQL Datasource
JNDI name app/schoolsystem
Data store helper class name Select a data store helper class
Figure 3.20 - Enter the Data source information
9. Select the Additional Properties > Custom properties on the right hand side.
Figure 3.21 - The additional Properties
10. Click the New button to create the new property
Figure 3.22 - Create a new property
3-9
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
11. Add url property and click OK to create the url property
Name url
Value jdbc:mysql://localhost/schoolsystem
Figure 3.23 - Enter the property information
12. Click Save to apply all previous JDBC and datasource setting
Figure 3.24 - To save the property
13. Select the J2EE Connector Architecture (J2C) authentication data entries. It can create the data entries of
username and password to connect to database.
Figure 3.25 - Select J2EE Connector Architecture (J2C) authentication data entries
3-10
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
14. Click New to create the user IDs and password.
Figure 3.26 - Create a new user ID and password
15. Enter the Alias, User ID and Password and click Apply to save and return to the MySQL Datasource Page.
Figure 3.27 - Enter information for create user
16. Select the previously created username and password on Container-managed authentication and then click Apply.
Figure 3.28 - Select the Container-managed authentication
17. Select the MySQL Datasource to Test connection
Figure 3.29 - Select Test connection
3-11
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
18. The test connection is successful
Figure 3.30 - The connection successful message
Configuring the Datasource on DB-VA
You have setup the datasource on the WebSphere and JNDI name called "app/schoolsystem" . You can configure the
datasource connection to make the web application to use the datasource on the Server.
1. From the menu bar, select Tools > Object Relational Mapping (ORM) > Generate Code ... to open the Database
Code Generation dialog box.
Figure 3.31 - To generate code
3-12
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
2. Select the Database tab and select the Connection option from JDBC to Datasource.
Figure 3.32 - Database configuration for using Data sources
3. Enter the following information to configure the datasource on WebSphere Server
Dialect [Link]
Datasource JNDI Name app/schoolsystem
JNDI Provider URL (empty)
JNDI InitialContextFactory class [Link]
User name (connect database user name)
Password (connect database password)
TransactionManagerLookup class [Link]
TransactionFactory class [Link]
Click OK to regenerate the code.
4. Copy the new configuration files from [Link]\src\ormmapping folder to [Link]\classes
folder and use the jar command to create a new war file.
5. Uninstall the schoolsystem application on WebSphere Application server.
6. Repeat the Deploying to WebSphere steps to redeploy the application. The web application can then use the
datasource on the server to connect to database.
3-13
Deployment Guide for Java Chapter 3 – Deploying Enterprise Java Web Application to IBM WebSphere
3-14