This chapter describes the process for migrating the main components of a typical J2EE application from Sun ONE Application Server 6.x to Application Server 8.2. This chapter highlights some of the problems posed during the migration of each type of component and suggests practical solutions to overcome such problems.
For this migration process, the J2EE application presented is called iBank and is based on the actual migration of the iBank application from Sun ONE Application Server 6.x to Application Server 8.2. iBank simulates an online banking service and covers all of the aspects traditionally associated with a J2EE application.
The major points of the J2EE specification covered by the iBank application are:
Servlets, especially with redirection to JSP pages (model-view-controller architecture)
JSP pages, especially with static and dynamic inclusion of pages
JSP custom tag libraries
Creation and management of HTTP sessions
Database access through the JDBC API
Enterprise Java Beans: Stateful and Stateless session beans, CMP and BMP entity beans
Assembly and deployment in line with the standard packaging methods of the J2EE application
Before starting the migration process, it in important to understand the differences in the deployment descriptors. For detailed information, see Migrating Deployment Descriptors.
To start, chooseApplication Server 8.2 as the target migration server. Install the server in the migration environment. For step-by-step instructions on how to install the software, see the Sun Java System Application Server 8.2 Installation Guide.
If you are using Migration Tool for Sun Java System Application Server 8.2 to migrate the components, install the tool. The Migration Tool can be downloaded from the following location:
For information on how to use the Migration Tool for Sun Java System Application Server 8.2, see the Migration Tool online help. The iBank application is bundled with the tool.
The iBank application has the following directory structure:
/docroot contains HTML, JSP’s and Image files in its root. It also contains the source files for servlets and EJBs in the sub-folder WEB-INF\\classes following the package structure com.sun.bank.*. A war file is generated using this directory.
/session contains the source code for the session beans following the package structure com.sun.bank.ejb.session. This directory forms the EJB module for the session beans.
/entity contains the entity beans following the package structure com.sun.bank.ejb.entity. This directory would form the EJB module for entity beans.
/misc contain the SQL scripts for the database setup.
Most of the migration is done by the Migration Tool. Some migration steps that must be done manually are documented in the Migration Tool’s user’s guide and in the documentation for the iBank sample application.
To deploy an application to the target server, you must add a connection pool, add a JDBC resource and a persistence manager.
This section discusses the following topics:
Before you begin these steps, ensure that the domain to which the application will be deployed is in the running state. These instructions assume that the application will be deployed to the default domain, domain1.
Use the asadmin utility in the Application Server's bin directory to perform these tasks.
A JDBC connection pool is a group of reusable connections for a particular database. Because creating each new physical connection is time consuming, the server maintains a pool of available connections to increase performance. When an application requests a connection, it obtains one from the pool. When an application closes a connection, the connection is returned to the pool.
Use the asadmin create-jdbc-connection-pool command to add a connection pool to the server. The syntax of the command is given below.
asadmin create-jdbc-connection-pool --user admin_user --password admin_password --host localhost --port portno --datasourceclassname dsclassname --property User=ibank_user:Password=ibank_user:URL_PROP=db_url TMB
where, dsclassname is:
oracle.jdbc.pool.OracleDataSource for Oracle
com.pointbase.jdbc.jdbcDataSource for PointBase
url for Oracle
DatabaseName for PointBase
jdbc:oracle:thin:@ORACLE_HOST:1521:SID for Oracle, where ORACLE_HOST is the machine name/IP address on which the database is installed, and SID is the System ID of the Oracle database.
jdbc:pointbase:server://POINTBASE_HOST:9092/migration-samples for Pointbase, where POINTBASE_HOST is the machine name/IP address on which the database is installed. This will be localhost in most cases.
Use the asadmin create-jdbc-resource command to add resource.
asadmin create-jdbc-resource --user admin_user --password admin_password --host localhost --port portno --connectionpoolid TMB jdbc/IBank
A persistence manager is required for backward compatibility. To run on version 7 of the Application Server, a persistent manager resource was required for applications with container-managed persistent beans (a type of EJB component).
Use the asadmin create-persistence-resource command.
asadmin create-persistence-resource --user admin_user --password admin_password --host localhost --port portno --connectionpoolid TMB --factoryclass com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerFactoryImpljdo/pmf
Application Server 8.2primarily supports the J2EE model wherein applications are packaged in the form of an enterprise archive (EAR) file (extension .ear). The application is further subdivided into a collection of J2EE modules, packaged into Java archives (JAR, extension .jar) for EJBs and web archives (WAR, extension .war) for servlets and JSPs.
All the JSPs and Servlets must be packaged into WAR file, all EJBs into the JAR file and finally the WAR and the JAR file together with the deployment descriptors in to the EAR file. This EAR file is a deployable component.
The last step is to deploy the application on Application Server 8.2. The process for deploying an application is described below:
TheApplication Server 8.2 asadmin command includes a help section on deployment that is accessible from the Help menu.
The command line utility asadmin can be invoked by executing asadmin.bat file in Windows and asadmin file in Solaris Operating Environment that is stored in Application Server installation’s bin directory.
At asadmin prompt, the command for deployment looks like this:
asadmin> deploy -u username -w password -H hostname -p adminport absolute_path_to_application
After restarting the Application Server 8.2, open a browser, and go to the following URL to test the application:
When prompted, enter one of the available user names and passwords. The main menu page of the iBank application displays.