Welcome!

Weblogic Authors: Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Migrating a JBoss EJB Application to WebLogic

Modify a JBoss application for the WebLogic Server

The JBoss open source application server is commonly used in the development phase of a J2EE project. In the production phase the commercial BEA WebLogic server is preferred because of its enhanced set of features. Without modifications, an application developed in JBoss does not deploy in WebLogic server.

The deployment descriptors for the WebLogic server are different from the JBoss deployment descriptors. An application may be migrated to WebLogic by converting the vendor-specific deployment descriptors to WebLogic. In this tutorial an EJB application developed in JBoss will be migrated to WebLogic with MySQL as the database.

Preliminary Setup
Download and install the BEA WebLogic server (www.bea.com/framework.jsp?CNT=overview.htm &FP=/content/products/weblogic/server). Create a server domain. Download the MySQL JDBC driver JAR file (www.mysql.com/products/connector/j/) and the MySQL database server (www.mysql.com/products/mysql/). Develop a Java application or obtain an XSLT utility to transform the JBoss deployment descriptors to WebLogic deployment descriptors with an XSLT.

Without deployment descriptor conversions, an application developed for JBoss does not deploy in WebLogic. In this tutorial, we will migrate an example entity EJB application developed in JBoss to WebLogic by converting the JBoss deployment descriptors to WebLogic deployment descriptors.

The example application consists of a Catalog entity EJB. The EJB's bean class (CatalogBean.java) is shown in Listing 1. The remote interface (Catalog.java) and home interface (CatalogHome.java) are shown in Listing 2 and Listing 3. The entity EJB classes do not need to be modified for deploying a JBoss EJB application to WebLogic. Only the deployment descriptors for an EJB are required to be modified.

Configuring WebLogic JDBC
In this section a JDBC connection will be configured with the MySQL database from the WebLogic server. First a JDBC Connection Pool is configured and subsequently a JNDI data source to access the JDBC connection pool is configured. Add the MySQL database driver JAR file, mysql-connector-java-3.0.16-ga-bin.jar, to the CLASSPATH variable of the examples server. The CLASSPATH variable for the WebLogic server is set in the <BEA>\user_projects\domains\mydomain\startWebLogic script. Double-click on the startWebLogic script file to start the WebLogic examples server. The server gets started on port 7001. Login to the WebLogic Administration Console with the URL http://localhost:7001/console. The login page for the Administration Console gets displayed. In the login page specify user name and password and log in to the administration console.

In the administration console select the Services>JDBC node. To configure a JDBC connection pool, right-click on the Connection Pools node and select Configure a new JDBCConnectionPool. In the Choose database frame displayed select MySQL as the Database Type. Select MySQL's Driver (Type 4) as the Database Driver. Click on the Continue button. Specify the connection properties for the JDBC connection. In the Database Name field specify test, the example MySQL database. In the Host Name field specify localhost. In the Database User Name field specify root. A password is not required to login to MySQL database with the root username, but the WebLogic server requires a password to be specified. Specify the password for the user name. Click on the Continue button.

In the Test database connection frame, the MySQL driver com.mysql.jdbc.Driver is specified in the Driver Classname field. The MySQL driver is used to establish a connection with the MySQL database. In the URL field specify jdbc:mysql://localhost/test as the connection URL for the database. To test the JDBC connection to the database click on the Test Driver Configuration button. If a connection gets established with the database, a "connection successful" message gets displayed. In the Create and deploy frame, select the server on which the connection pool is to be deployed. Click on the Create and deploy button to deploy the JDBC connection pool on the server. The configured connection gets deployed on the examples server and a node for the connection pool gets added to the JDBC>Connection Pools node. To modify the configuration of the connection pool, select the connection pool node and modify the settings in the different tabs: General, Target and Deploy, Monitoring, Control, Testing, Connections.

Next, configure a data source in the WebLogic server. Right-click on the Services>JDBC node and select Configure a new JDBCTxDataSource. Specify a data source name. In the JNDI Name field specify a JNDI name for the data source - MySQLDS for example. Click on the Continue button. In the Connect to connection pool frame, select a connection pool from the list of connection pools. Select the connection pool that was configured in the previous section and click on the Continue button. In the Target the data source frame select a server as the target server for the data source. Click on the Create button. The configured data source gets deployed on the examples server and a node for the data source gets added to the Data Sources node. To modify the data source select the data source node and modify the settings in the different tabs: Configuration, Target, and Deploy. The data source is available with the JNDI name MySQLDS, which was specified in the data source configuration.

Converting the JBoss EJB Application
In the previous section the WebLogic server was configured with the MySQL database. In this section we'll convert the JBoss EJB application to a WebLogic EJB application, which involves converting the deployment descriptors. A JBoss entity EJB application consists of the EJB deployment descriptors (ejb-jar.xml, jboss.xml, and jbosscmp-jdbc.xml), the bean class (CatalogBean.java), the remote interface (Catalog.java), and the home interface (CatalogHome.java). To deploy the entity EJB in the JBoss server, an EJB JAR file is created; this EJB JAR file has the structure:

META-INF/
  ejb-jar.xml
  jboss.xml
  jbosscmp-jdbc.xml
CatalogBean.class
Catalog.class
CatalogHome.class

More Stories By Deepak Vohra

Deepak Vohra is a Sun Certified Java 1.4 Programmer and a Web developer.

More Stories By Ajay Vohra

Ajay Vohra is a senior solutions architect with DataSynapse Inc.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.