Migrating the iBank Application from BEA WebLogic Application Server 5.1 to Sun Java System Application Server 8

Version 1.0

This document explains how to use the Migration Tool for Sun Java System Application Server 8 (hereafter called the Migration Tool) to migrate the iBank application from the BEA WebLogic Application Server 5.1 source server to the Sun Java System Application Server 8 target server. The document also explains how to assemble, deploy, and run the sample application on the target server.

This document contains the following sections:

Overview
Prerequisites
Migrating the Application
Deploying and Running the Migrated Application on the Target Server

Overview

iBank Overview briefly describes the iBank sample application.


Prerequisites

The following section describes what you need to do before you begin this exercise.

Database Setup

The following sections provide step-by-step instructions for setting up a database to use with the iBank example:


Migrating the Application

This section describes how to migrate the application from the source server (BEA WebLogic Application Server 5.1) to the target server (Sun Java Systems Application Server 8).

  1. Set the following environment variables that are used by the Migration Tool's build scripts:

    • JAVA_HOME: J2SE SDK 1.4 installation directory
    • J2EE_HOME: Sun Java Systems Application Server 8 installation directory
    • ASMT_HOME: Migration Tool installation directory
    • AS_HOME: bin directory of the Sun Java Systems Application Server 8 installation
    • CLASSPATH: Include any application-specific library classes that are required for compiling the application

  2. Start the Migration Tool in GUI mode:
  3. On Solaris:

      <ASMT_HOME>/bin> sh asmigrate.sh -u

    On Windows:

      <ASMT_HOME>\bin> asmigrate -u

    Invoking the Migration Tool in Command-Line Mode explains how to run the Migration Tool in command-line mode.

  4. Specify the Source Application (Input) details:

    1. Select "Source" and specify the directory <ASMT_HOME>/examples/weblogic_5_1/iBank as input to the Migration Tool.

    2. Select the Source Server as BEA WebLogic Application Server 5.1 from the dropdown list.

  5. Specify the Target Application (Output) details:

    1. Specify a Directory path of your choice to the location where the migrated output application should be written. From here on, this document will refer to this directory path as <OUTPUT_DIR>.
    2. Select the Target Server from the dropdown list. Your only choice is Sun Java Systems Application Server 8.

  6. Select whether or not to use the advanced migration options:

    1. If you do not select any advanced migration options, you do not need to modify the migrated source code of the application before you build and deploy the application, as explained in step 7.

    2. If you select advanced migration options for upgrading CMP EJB 1.1 to 2.0, you need to check the following checkboxes:

      • Migrate CMPs from EJB 1.1 to 2.0 specs
      • Overwrite conflicting Accessors
      • Comment out setters for primary key fields

      If you select these options, the migration tool will upgrade all CMP beans, in this particular case, to EJB 2.0 version of specifications. For more information about the ramifications of selecting these options, see the sections of the tool's online help that are associated with each of these options.

  7. After making the appropriate selections, press the Migrate button.

    Depending on the options you selected during the migration process, the following files may show up in the "Files that failed to Migrate" section of the migration report:

    • <ASMT_HOME>/examples/weblogic_5_1/iBank/entity/com/sun/bank/ejb/entity/AccountEJB.java

      This file fails only if you selected the Migrate CMPs from EJB 1.1 to 2.0 specs option under the Advanced options.

      Reason of Failure:

      If the migration tool finds that, in a particular CMP entity bean, there is a finder method in the home interface which has a java.util.Enumeration as return type, it will fail to upgrade this bean to EJB 2.0 specification, because such an upgrade would violate the specification.

      Remedial Action:

      The bean that fails the migration can still be modified by the migration tool to make it deployable on Application Server 8. However, if the EJB 2.0 upgrade is required, you must change the return type of the finder method and modify the client code wherever this method is being called.

    • <ASMT_HOME>/examples/weblogic_5_1/iBank/docroot/WEB-INF/classes/com/sun/bank/servlets/LoginServlet.java

      This file will fail irrespective of the Advanced options you select.

      Reason for Failure:

      The init() method of this servlet contains a call to System.setErr(PrintStream err). This method is cannot be called by an application according to the default Application Server 8 security policy. The migration tool detects calls to such method calls and flags such files as failed in the migration report.

      Remedial Action:

      Take one of the following remedial actions:

      1. Comment out the offending method call. Open the LoginServlet.java file in the <OUTPUT_DIR>/iBank/docroot/WEB-INF/classes/com/sun/bank/servlets directory and comment out the call to the function System.setErr(PrintStream PrintStream_object_name).

      2. Modify the Application Server 8 security settings to allow the offending method call. This is explained in step 4 in the "Deploying and Running the Migrated Application on the Target Server" section.

    The Migration Tool creates a directory structure that contains the migrated source files and generated build scripts in the output directory that you selected.

  8. If you used the advanced CMP Migration options, change to the <OUTPUT_DIR>/iBank/entity/com/sun/bank/ejb/entity directory and open the AccountTypeEjb.java and TransactionEjb.java files in an editor. Then:

    1. Search for and replace (paying attention to case) all occurrences of “double” with “BigDecimal”.

    2. Go to Line # 426 in TransactionEjb.java and replace “setTransAmount(iasmtTransAmount.doubleValue ());” with “setTransAmount(iasmtTransAmount);”.

  9. Optionally, use the capture-schema utility in the bin directory of the Application Server 8 installation to create the mySchema.dbschema file. If you do not create the mySchema.dbschema file and leave the field blank in the migration tool, the tool will automatically generate the file for you. You have the option of overriding this file and specifying your own, should you choose to do so.

    If you created your own mySchema.dbschema file, copy it to the <OUTPUT_DIR>/iBank/entity/ directory.

  10. Change to the <OUTPUT_DIR>/iBank/src directory and run the appropriate build script to generate the ibank.ear file:

    • On Solaris: sh build_ear.sh

    • On Windows: build_ear

    The build script generates the <OUTPUT_DIR>/iBank/src/asmtbuild/ibank.ear file, which you will deploy on the target server.



Deploying and Running the Migrated Application on the Target Server

  1. Configure database connectivity for Application Server 8, the target server.

    Before you begin these steps, make sure 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 8 bin directory to:

    1. Add a connection pool:
        asadmin create-jdbc-connection-pool 
         --user  admin_user 
         --password admin_password 
         --host localhost 
         --port  4848 
         --datasourceclassname dsclassname  
         --property User=ibank_user:Password=ibank_user:URL_PROP=db_url TMB

      Replace the variables shown in a blue font with values appropriate for your own environment.

      dsclassname should be:

      • oracle.jdbc.pool.OracleDataSource for Oracle
      • com.pointbase.jdbc.jdbcDataSource for PointBase

      URL_PROP should be:

      • url for Oracle
      • DatabaseName for PointBase

      db_url should be:

      • 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.

      Note: You must escape all of the ":" characters in the URLs listed above with a double backslash ("\\") on Solaris and a single backslash ("\") on Windows to avoid errors while running the create-jdbc-connection-pool command.

    2. Add a JDBC resource:
        asadmin create-jdbc-resource 
         --user admin_user 
         --password admin_password 
         --host localhost 
         --port 4848 
         --jdbcjndiname TMB jdbc/IBank

      Replace the variables shown in a blue font with values appropriate for your own environment.

    3. Add a persistence manager:
        asadmin create-persistence-resource 
         --user admin_user 
         --password admin_password 
         --host localhost 
         --port 4848 
         --connectionpoolid TMB 
         --factoryclass com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerFactoryImpl 
         jdo/pmf

      Replace the variables shown in a blue font with values appropriate for your own environment.

    4. Modify the target server's classpath.

      Note: Complete this step only if you are using the Oracle database. The driver class for PointBase is already in the server classpath.

      1. Add the JDBC driver classes to the server classpath:

        1. Get the current classpath prefix of the domain:
            asadmin get --user admin_user 
             --password admin_password 
             --host localhost 
             --port 4848 
             server.java-config.classpath_prefix

          Replace the variables shown in a blue font with values appropriate for your own environment.

          Write down the prefix. For this example, assume that the classpath prefix is CLASSPATH.


        2. Set the classpath to include the Oracle driver classes:
            asadmin set --user admin_user
             --password admin_password 
             --host localhost
             --port 4848
             server.java-config.classpath_prefix=CLASSPATH${path.separator}PATH_TO_DRIVER_CLASSES

          Replace the variables shown in a blue font with values appropriate for your own environment.

          The PATH_TO_DRIVER_CLASSES variable points to the location of classes12.zip, the driver classes for the Oracle database.


      2. Follow the instructions in the previous step to add the asmt-rt.jar file, which is located in the <ASMT_HOME>/lib directory, to the server's classpath.

      Note: See the Preparing the Sun Java Systems Application Server 8 to Run the Migrated Applications section for additional information.

  2. Restart the server to use the changes:
      asadmin stop-domain
      asadmin start-domain
  3. Deploy the application:
      asadmin deploy --user admin_user 
       --password admin_password 
       --host localhost 
       --port 4848 
       <OUTPUT_DIR>/iBank/src/asmtbuild/ibank.ear

    Replace the variables shown in a blue font with values appropriate for your own environment.

  4. You need to modify the server.policy file only if the call to System.setErr(PrintStream err) (described in the step 6 of the "Migrating the Application" section) is not commented out. If this method call has been commented out or deleted, proceed to the next step.

    1. Application Server 8 has its own standard J2SE policy file, server.policy, located in the server's domains/domain1/config directory. Open the server.policy file in a text editor.

    2. At the end of the server.policy file, add the following lines:
        grant codeBase "file:${com.sun.aas.installRoot}
        /domains/domain1/applications/j2ee-apps/ibank_1/-" {
        permission java.lang.RuntimePermission "setIO";
        };
    3. Save the server.policy file and restart the server so the revised policy file takes effect.

      See the postrun section of the user's guide for additional information about the security policy of Application Server 8.

  5. Run the application:

    1. Run the deployed iBank application by accessing the following URL:
        http://localhost:<port>/ibank

    2. When prompted, enter "jatkins" for the username and "monday" for the password.


Index
Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved.