Previous Next
Deployment Guide for Java Chapter 2 - Deploying Enterprise Java Web Application to BEA WebLogic

Chapter 2 - Deploying Enterprise Java Web Application to BEA WebLogic

DB Visual ARCHITECT (DB-VA) provides different kinds of template for user to generate Java code. The template will optimize the configuration of generated Java Code and select jar files for different application server or standalone Java application. In this chapter, we will deploy enterprise Java web application to BEA WebLogic. When you deploy the web application on application server, you can select to use the JDBC or datasource to connect the database.

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 steps on a WebLogic Server. The Example of Programmer's Guide for java - Chapter 3 is deployed on a JBoss Server, we need to modify some configuration before deploy on a WebLogic Server. Finally, we will configure the web application to use the datasource connection provide by WebLogic server to connect to database.

Preparing to Deploy to WebLogic

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 generate code before deploying on the WebLogic 8.1 Server.

  1. From the menu bar, select Tools > Object Relational Mapping (ORM) > Generate Code ... to open Database Code Generation dialog box.
  2. Figure 2.1 - To generate code
  3. Change Deploy To option from JBoss Application Server to WebLogic Application Server 8.1/9.0
  4. Figure 2.2 - Enter the deployment directory

    DB-VA helps you to select the corresponding Optional Jar files and set datasource options.

    Figure 2.3 - Select Optional Jar dialog
  5. Click OK to regenerate code.

Deploying Web Application to WebLogic 8.1

Now the orm.jar is updated and generate in JBoss Server deploy folder. You can copy the schoolsystem.war folder in JBoss Server deploy folder to the WebLogic 8.1 Server. The following is the steps to deploy on a WebLogic 8.1 Server.

  1. Find the antlr.jar file from DB-VA installation Directory\ormlib folder.
  2. Modify startWebLogic.cmd in WebLogic server domain (WEBLOGIC _HOME\user_projects\domains\mydomain) to add the antlr.jar to server classpath.
  3. The mydomain is a domain created by user to use Configuration Wizard provided by WebLogic.

    This sample adds antlr.jar to classpath:

    set CLASSPATH=C:\bea\user_projects\domains\mydomain\antlr.jar;%WEBLOGIC_CLASSPATH%;
    %POINTBASE_CLASSPATH%;%JAVA_HOME%\jre\lib\rt.jar;%WL_HOME%\server\lib\webservices.jar;
    C:\bea\user_projects\domains\mydomain\applications\SchoolProject\lib\mysql.jar;%CLASSPATH%
  4. Copy the schoolsystem.war folder from JBoss server's deploy folder to the WEBLOGIC_HOME\user_projects\domains\mydomain\applications folder.
  5. Figure 2.4 - The deployment directory
  6. Start WebLogic Server. Start menu > All Program > BEA WebLogic Platform 8.1 > User Projects > mydomain > Start Server.
  7. Figure 2.5 - To start the Application Server
  8. Visit the School System application on WebLogic Server.
  9. http://localhost:7001/schoolsystem

    Figure 2.6 - the index page of the project

Deploying Web Application to WebLogic 9.0

  1. Find antlr.jar file in the DB-VA installation Directory\ormlib folder.
  2. Modify setDomainEnv.cmd in WebLogic server domain "bin" folder (WEBLOGIC_HOME\user_projects\domains\base_domain\bin) and add the antlr.jar to classpath.

    The mydomain is a domain created by user to use Configuration Wizard provided by WebLogic.
    This sample adds antlr.jar to classpath:
    set CLASSPATH=DBVA_HOME\ormlib\antlr.jar;%PRE_CLASSPATH%;%WEBLOGIC_CLASSPATH%;
    %POST_CLASSPATH%;%WLP_POST_CLASSPATH%;%WL_HOME%\integration\lib\util.jar; C:\bea9.0\user_projects\domains\base_domain\autodeploy\SchoolProject\lib\mysql.jar;
  3. Copy the schoolsystem.war folder from JBoss server deploy folder to WEBLOGIC_HOME\user_projects\domains\base_domain\autodeploy folder.
  4. Figure 2.7 - The deployment directory
  5. Start WebLogic 9.0 Server. Windows Start > All Program > BEA Products > User Products > base_domain > Start Admin Server for WebLogic Server Domain
  6. Figure 2.8 - To start the Application Server
  7. Visit the SchoolProject application on WebLogic Server.
  8. http://localhost:7001/schoolsystem

    Figure 2.9 - The student Page

Configuring Datasource on WebLogic 8.1

WebLogic 8.1/9.0 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 WebLogic server.

  1. Add the JDBC driver for the classpath of the startWebLogic.cmd in WebLogic server domain (WEBLOGIC _HOME\user_projects\domains\mydomain). You can find the JDBC driver in schoolsystem.war\WEB-INF\lib. In this example we use the MySQL database, so you need to get the mysql.jar JDBC driver in the lib folder.
  2. This Sample adds the JDBC driver to classpath:

    set CLASSPATH= C:\bea\user_projects\domains\mydomain\antlr.jar;%WEBLOGIC_CLASSPATH%;
    %POINTBASE_CLASSPATH%;%JAVA_HOME%\jre\lib\rt.jar;%WL_HOME%\server\lib\webservices.jar;
    C:\bea\user_projects\domains\mydomain\applications\schoolsystem.war\lib\mysql.jar;%CLASSPATH%
  3. Go to WebLogic Server Administration Console (http://localhost:7001/console/login/LoginForm.jsp), type in username and password to login.
  4. Figure 2.10 - The Login page of BEA WebLogic
  5. Select mydomain > Services > JDBC > Connection Pools
  6. Figure 2.11 - Select the connection pool
  7. Select Configure a new JDBC Connection Pool
  8. Figure 2.12 - Configure the connection pool
  9. Select Database Type and Database Driver and click Continue
  10. Database Type MySQL
    Database Driver using com.mysql.jdbc.Driver
    Figure 2.13 - Select the Database Driver
  11. Fill in the Connection Properties and click Continue
  12. localhost
    Name MySQL Connection Pool
    Database Name schoolproject
    Host Name
    Port 3306
    Database User Name root
    Figure 2.14 - Enter the Database Configuration
  13. Click Test Driver Configuration. It will show the success message. Click Create and Deploy button to finish setup. Now the MySQL Connection Pool is created.
  14. Figure 2.15 - The database connection successful message
  15. Select the mydomain > Services > JDBC > Data Sources
  16. Figure 2.16 - Select the Data Sources
  17. Click Configure a new JDBC Data Sources
  18. Figure 2.17 - Configuration a new JDBC Data Sources
  19. Enter the Data Source information and click Continue
  20. Name MySQL Data Source
    JNDI Name app/schoolsystem
    JNDI path bound Honor Global Transactions
    Figure 2.18 - Configure the Data Sources
  21. Select the previously created MySQL Connection Pool and click Continue
  22. Figure 2.19 - Connect to the connection pool
  23. Select this Data Source for myserver. Click Create to finish setup.
  24. Figure 2.20 - Select the target Data Sources
    Figure 2.21 - Manage the Data Source

Configuring Datasource on WebLogic 9.0

  1. Add the JDBC driver for the classpath of the setDomainEnv.cmd in WebLogic server domain "bin" folder (WEBLOGIC_HOME\user_projects\domains\base_domain\bin). In this example, we use the MySQL database; you can find the JDBC driver in schoolsystem.war\WEB-INF\lib\mysql.jar.
  2. This sample adds the JDBC driver to classpath:

    set CLASSPATH=DBVA_HOME\ormlib\antlr.jar;%PRE_CLASSPATH%;%WEBLOGIC_CLASSPATH%;
    %POST_CLASSPATH%;%WLP_POST_CLASSPATH%;%WL_HOME%\integration\lib\util.jar; C:\bea9.0\user_projects\domains\base_domain\autodeploy\schoolsystem.war\lib\mysql.jar;
  3. Go to WebLogic Server Administration Console (http://localhost:7001/console/login/LoginForm.jsp), type in username and password to login.
  4. Figure 2.22 - The Login page
  5. Before configure any setting, you need to click the Lock & Edit button to modify, add or delete items in this domain
  6. Figure 2.23 - Lock an Edit the site
  7. Select JDBC > Data Sources
  8. Figure 2.24 - Select Data Sources
  9. Click New to create data source
  10. Figure 2.25 - The Data Sources summary
  11. Enter the New JDBC Data Source Properties
  12. Name MySQL Data Source
    JNDI app/schoolsystem
    Database Type MySQL
    Database Driver using com.mysql.jdbc.Driver
    Figure 2.26 - Create a New Data Sources
  13. Select the transaction of the data source to follow the diagram below:
  14. Figure 2.27 - Transaction options
  15. Enter the Connection Properties
  16. Database Name schoolsystem
    Host Name localhost
    Port 3306
    Database User root
    Figure 2.28 - The Connection Properties
  17. Click Test Configuration to test the connection properties and settings. If the settings are correct, it will show the succeeded message.
  18. Figure 2.29 - The Connection successful message
  19. Select the target of the setting data source; click Finish to create JDBC Data Source.
  20. Figure 2.30 - Select target server
    Figure 2.31 - The Data source is added
  21. Click Activate Changes button to apply the New Data Source Change setting for WebLogic Server
  22. Figure 2.32 - Activate Change

Configuring DataSource Connection on DB-VA

You have setup the datasource on the WebLogic 8.1 and 9.0 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 2.33 - To generate code
  3. Select the Database tab and select the Connection option from JDBC to Datasource.
  4. Figure 2.34 - The generate database configure for Data source
  5. Enter the following information to configure the datasource of WebLogic Server
  6. Dialect org.hibernate.dialect.MySQLInnoDBDialect
    Datasource JNDI Name app/schoolsystem
    JNDI Provider URL t3://localhost:7001
    JNDI InitialContextFactory class weblogic.jndi.WLInitialContextFactory
    User name (WebLogic Server login user name)
    Password (WebLogic Server login password)
    TransactionManagerLookup class org.hibernate.transaction.WeblogicTransactionManagerLookup
    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.
Follow the steps of Deploy Web Application to WebLogic 8.1 or Deploy Web Application to WebLogic 9.0 to redeploy the web application. After that it will use the datasource to connect to database in the WebLogic server.
Previous Next
Visual Paradigm International Limited
Website: www.visual-paradigm.com
E-mail: support@visual-paradigm.com