Previous Next
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

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.
  2. Figure 3.1 - To generate code
  3. Change Deploy To option from JBoss Application Server to Generic Application Server.
  4. 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
  5. Click OK to regenerate code.
  6. Copy the schoolsystem.war\src\ormmapping folder to schoolsystem.war\classes folder to make sure the configuration files are also updated.

Deploying Web Application to WebSphere

Now the orm.jar is updated and generated in the JBoss Server deploy folder.

  1. Open the command prompt to the schoolsystem.war folder in the JBoss deploy folder.
  2. Execute jar to create a war file in command prompt.
  3. The command to create a war file:

    jar - cvf schoolsystem.war .

    The schoolsystem.war file is created inside the schoolsystem.war folder

    Figure 3.4 - The war file
  4. Startup WebSphere Application Server 6. Start menu > All Program > IBM WebSphere > Application Server v6 > Profiles > AppSrv01 > Start the server.
  5. Figure 3.5 - Start the Server
  6. Go to Administration Console (http://localhost:9061/ibm/console) 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).
  7. Figure 3.6 - Login page
  8. Select Applications > Install New Application to install the schoolsystem.war file
  9. Figure 3.7 - Install New Application
  10. Select the War file and fill in the Context Root (schoolsystem)
  11. Figure 3.8 - Select the file
  12. Click Next to finish the installation.
  13. Click Save to Master Configuration and click Save in this page to apply all changes.
  14. Figure 3.9 - the successful deploy message
  15. Start the new deploy SchoolProject Web Application. Select Applications > Enterprise Application.
  16. Figure 3.10 - Select Enterprises Application
  17. Select schoolsystem_war and click the Start button to startup the Web Application on the server.
  18. Figure 3.11 - Select the Web Application
  19. Go to (http://localhost:9081/schoolsystem/index.html) to confirm the web application is running
  20. 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 (http://localhost:9061/ibm/console ) to login.
  2. Figure 3.13 - The Administrator Console
  3. Select Resources > JDBC Providers
  4. Figure 3.14 -
  5. Click New button to create MySQL JDBC provider
  6. Figure 3.15 - the JDBC Provider
  7. In Choose a type of JDBC provider, set all options to User-defined
  8. Figure 3.16 - Create a new JDBC provider
  9. Fill in general properties and click Apply.
  10. Name MySQL JDBC provider
    Classpath C:\DevelopApps\jboss-4.0.3SP1\server\default\deploy\schoolsystem.war\WEB-INF\lib\mysql.jar
    Implementation class name com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
    Figure 3.17 - The General Properties
  11. Select the Additional Properties > Data sources on the right hand side.
  12. Figure 3.18 - The Additional properties
  13. Click the New button to create new MySQL Data source.
  14. Figure 3.19 - New a Data source
  15. Fill in new MySQL Data source information and click Apply
  16. 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
  17. Select the Additional Properties > Custom properties on the right hand side.
  18. Figure 3.21 - The additional Properties
  19. Click the New button to create the new property
  20. Figure 3.22 - Create a new property
  21. Add url property and click OK to create the url property
  22. Name url
    Value jdbc:mysql://localhost/schoolsystem
    Figure 3.23 - Enter the property information
  23. Click Save to apply all previous JDBC and datasource setting
  24. Figure 3.24 - To save the property
  25. Select the J2EE Connector Architecture (J2C) authentication data entries. It can create the data entries of username and password to connect to database.
  26. Figure 3.25 - Select J2EE Connector Architecture (J2C) authentication data entries
  27. Click New to create the user IDs and password.
  28. Figure 3.26 - Create a new user ID and password
  29. Enter the Alias, User ID and Password and click Apply to save and return to the MySQL Datasource Page.
  30. Figure 3.27 - Enter information for create user
  31. Select the previously created username and password on Container-managed authentication and then click Apply.
  32. Figure 3.28 - Select the Container-managed authentication
  33. Select the MySQL Datasource to Test connection
  34. Figure 3.29 - Select Test connection
  35. The test connection is successful
  36. 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.
  2. Figure 3.31 - To generate code
  3. Select the Database tab and select the Connection option from JDBC to Datasource.
  4. Figure 3.32 - Database configuration for using Data sources
  5. Enter the following information to configure the datasource on WebSphere Server
  6. Dialect org.hibernate.dialect.MySQLInnoDBDialect
    Datasource JNDI Name app/schoolsystem
    JNDI Provider URL (empty)
    JNDI InitialContextFactory class com.ibm.websphere.naming.WsnInitialContextFactory
    User name (connect database user name)
    Password (connect database password)
    TransactionManagerLookup class org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
    TransactionFactory class org.hibernate.transaction.JTATransactionFactory
    Click OK to regenerate the code.
  7. Copy the new configuration files from schoolsystem.war\src\ormmapping folder to schoolsystem.war\classes folder and use the jar command to create a new war file.
  8. Uninstall the schoolsystem application on WebSphere Application server.
  9. 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.

Previous Next
Visual Paradigm International Limited
Website: www.visual-paradigm.com
E-mail: support@visual-paradigm.com