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
- Preparing to Deploy to WebLogic 8.1/9.0
- Deploying Web Application to WebLogic 8.1
- Deploying Web Application to WebLogic 9.0
- Configuring Datasource on WebLogic 8.1
- Configuring Datasource on WebLogic 9.0
- 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 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.
- From the menu bar, select Tools > Object Relational Mapping (ORM) > Generate Code ... to open Database Code Generation dialog box.
- Change Deploy To option from JBoss Application Server to WebLogic Application Server 8.1/9.0
DB-VA helps you to select the corresponding Optional Jar files and set datasource options.
- 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.
- Find the antlr.jar file from DB-VA installation Directory\ormlib folder.
- Modify startWebLogic.cmd in WebLogic server domain (WEBLOGIC _HOME\user_projects\domains\mydomain) to add the antlr.jar to server 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=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%
- Copy the schoolsystem.war folder from JBoss server's deploy folder to the WEBLOGIC_HOME\user_projects\domains\mydomain\applications folder.
- Start WebLogic Server. Start menu > All Program > BEA WebLogic Platform 8.1 > User Projects > mydomain > Start Server.
- Visit the School System application on WebLogic Server.
http://localhost:7001/schoolsystem
Deploying Web Application to WebLogic 9.0
- Find antlr.jar file in the DB-VA installation Directory\ormlib folder.
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;
- Copy the schoolsystem.war folder from JBoss server deploy folder to WEBLOGIC_HOME\user_projects\domains\base_domain\autodeploy folder.
- Start WebLogic 9.0 Server. Windows Start > All Program > BEA Products > User Products > base_domain > Start Admin Server for WebLogic Server Domain
- Visit the SchoolProject application on WebLogic Server.
http://localhost:7001/schoolsystem
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.
- 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.
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%
- Go to WebLogic Server Administration Console (http://localhost:7001/console/login/LoginForm.jsp), type in username and password to login.
- Select mydomain > Services > JDBC > Connection Pools
- Select Configure a new JDBC Connection Pool
- Select Database Type and Database Driver and click Continue
| Database Type |
MySQL |
| Database Driver |
using com.mysql.jdbc.Driver |
- Fill in the Connection Properties and click Continue
localhost
| Name |
MySQL Connection Pool |
| Database Name |
schoolproject |
| Host Name |
| Port |
3306 |
| Database User Name |
root |
- 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.
- Select the mydomain > Services > JDBC > Data Sources
- Click Configure a new JDBC Data Sources
- Enter the Data Source information and click Continue
| Name |
MySQL Data Source |
| JNDI Name |
app/schoolsystem |
| JNDI path bound |
Honor Global Transactions |
- Select the previously created MySQL Connection Pool and click Continue
- Select this Data Source for myserver. Click Create to finish setup.
Configuring Datasource on WebLogic 9.0
- 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.
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;
- Go to WebLogic Server Administration Console (http://localhost:7001/console/login/LoginForm.jsp), type in username and password to login.
- Before configure any setting, you need to click the Lock & Edit button to modify, add or delete items in this domain
- Select JDBC > Data Sources
- Click New to create data source
- Enter the New JDBC Data Source Properties
| Name |
MySQL Data Source |
| JNDI |
app/schoolsystem |
| Database Type |
MySQL |
| Database Driver |
using com.mysql.jdbc.Driver |
- Select the transaction of the data source to follow the diagram below:
- Enter the Connection Properties
| Database Name |
schoolsystem |
| Host Name |
localhost |
| Port |
3306 |
| Database User |
root |
- Click Test Configuration to test the connection properties and settings. If the settings are correct, it will show the succeeded message.
- Select the target of the setting data source; click Finish to create JDBC Data Source.
- Click Activate Changes button to apply the New Data Source Change setting for WebLogic Server
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.
- From the menu bar, select Tools > Object Relational Mapping (ORM) > Generate Code ... to open the Database Code Generation dialog box.
- Select the Database tab and select the Connection option from JDBC to Datasource.
- Enter the following information to configure the datasource of WebLogic Server
| 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.
- 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.
|
|
| Visual Paradigm International Limited |
| Website: |
www.visual-paradigm.com |
| E-mail: |
support@visual-paradigm.com |
|