WebLogic Server 6.1 Code Examples, BEA Systems, Inc.

Package examples.tutorials.migration.banking

This WebLogic 5.1 example shows how EJB, JSP, servlet, RMI, and ACL security work together.

See:
          Description

Interface Summary
Account The methods in this interface are the public face of AccountBean.
AccountHome This interface is the home interface for the EJBean AccountBean, which in WebLogic is implemented by the code-generated container class AccountBeanC.
RMILogger This remote interface is implemented by RMILoggerImpl.
 

Class Summary
AccountBean AccountBean is an EntityBean.
BankAppServlet BankAppServlet is a servlet.
BankConstants Constants class
Client This class demonstrates calling an entity EJBean, followed by two exercises:
RMILoggerImpl With WebLogic RMI, you don't need to extend UnicastRemoteObject.
 

Exception Summary
ProcessingErrorException This class is used with the WebLogic EJBean container-managed example package.
 

Package examples.tutorials.migration.banking Description

This WebLogic 5.1 example shows how EJB, JSP, servlet, RMI, and ACL security work together. It is the basis for the migration tutorial, which details the process of migrating a WebLogic 5.1 application to a WebLogic 6.0 server. This sample application uses the container managed Account EJB. The application flows as follows:

  1. From the login.html page, the user specifies an account by entering an account number.
  2. The BankAppServlet handles the request by looking up the account. If the account is found, the BankAppServlet passes the Account remote stub to AccountDetail.jsp.
  3. AccountDetail.jsp displays the account data. The user can alter the account by depositing or withdrawing money.
  4. Control is sent back to BankAppServlet, which handles the request by interacting with the EJB to record and validate the deposit or withdrawal.
  5. RMI Logging logs processing that take place in the BankAppServlet. This is in addition to the Account EJB logging.
  6. All exceptions are redirected to the Error.jsp to be displayed.

Additional Resources for examples.tutorials.migration.banking
Login.html The HTML to look up the account.
AccountDetail.jsp The JSP that displays the account data.
Error.jsp The JSP that displays the error.

Since this is a WebLogic 5.1 example, the following instructions are specific to WebLogic 5.1 server:

  1. Prepare the environment
  2. Build the example
  3. Configure the server
  4. Run the example

Prepare the environment

The following steps will prepare your environment to run the banking application, and the banking application to run in your environment.
  1. Create an installation directory for the sample application, "migrationserver", under your WebLogic 5.1 root directory.
  2. In the "migrationserver" directory, create the following subdirectories: "clientclasses," "public_html\images," "serverclasses," and "servletclasses."
  3. In a command console, navigate to the sample application’s directory and run the build script.

Build the example

Set up your development shell as described in Setting up your environment.

We provide separate build scripts for Windows NT and UNIX:

These scripts will build the example and place the files in the correct locations in your WebLogic Server distribution:

Several necessary files are not copied by the build script and need to be copied manually.

Configure the server

  1. Set the database persistence

    With database persistence, each instance of an EJBean is written to a row in a table. The table (ejbAccounts) must be created and exist in the database before the example is run. If you are using the evaluation copy of Cloudscape that is included with WebLogic, this table has already been created in the "demo" database.

    You'll need to:

    1. If you're using a database other than Cloudscape, you'll need to create the table in your database using an appropriate SQL statement such as
      "create table ejbAccounts (id varchar(15), bal float, type varchar(15))"

    2. Uncomment the following line from weblogic.properties:
      # Add a TXDataSource for the connection pool: 
      weblogic.jdbc.TXDataSource.weblogic.jdbc.jts.demoPool=demoPool 
      
    3. For all databases, setup a connection pool in the weblogic.properties file. For your convenience, a template is included in the file; search for "weblogic.jdbc.connectionPool.demoPool", and uncomment and edit the appropriate lines:
        # You can use this connection pool with any of the EJBean examples.
        # Uncomment to use:
        weblogic.jdbc.connectionPool.demoPool=\
               url=jdbc:cloudscape:demo,\
               driver=COM.cloudscape.core.JDBCDriver,\
               initialCapacity=1,\
               maxCapacity=2,\
               capacityIncrement=1,\
               props=user=none;password=none;server=none
      You can use this pool for Cloudscape. For other databases, you'll need to set an appropriate url and driver, such as
      	  url=jdbc:weblogic:oracle,\
      	  driver=weblogic.jdbc.oci.Driver,\

    4. You'll need to add an access control list (ACL) for users of the pool:
        # Add an ACL for the connection pool:
        weblogic.allow.reserve.weblogic.jdbc.connectionPool.demoPool=everyone

      If you need more information about how to use connection pools, read Using WebLogic JDBC: Using connection pools.

  2. To deploy the EJBean, add the path to the .jar file to the weblogic.ejb.deploy property by uncommenting the line in the weblogic.properties that begins with weblogic.ejb.deploy. You'll need to adjust the property if the location of the files differs from the installed location. In this case, we'll be deploying the app_banking.jar.

    Note: If you're running under the Microsoft SDK for Java, you'll also need to add the path to the .jar to the CLASSPATH for your WebLogic Server.

  3. Register the Banking Servlet by uncommenting the following line in the weblogic.properties file:
    weblogic.httpd.register.banking=examples.tutorials.migration.banking.BankAppServlet
    

    For more help with registering servlets, see the WebLogic Administrators Guide document, Setting WebLogic properties.

  4. Register RMILoggerImpl as a startup class by uncommenting the following property in the weblogic.properties file:
    weblogic.system.startupClass.rmilogger=examples.tutorials.migration.banking.RMILoggerImpl
    

Run the example

  1. Start the WebLogic Server.

    If you're starting the Server from the command line, you'll need to add an entry such as c:/weblogic/eval/cloudscape/lib/cloudscape.jar to the Java system classpath before starting the server, as described in the Administrators Guide Setting up and starting the WebLogic Server.

    You can check that the EJBean has been deployed correctly either by checking the server command line window, or by opening the Console and examining "EJB" under the "Distributed objects"; you should see beanManaged.AccountHome deployed, and can monitor its activity.

  2. Use a web browser to load the following URL:
    http://localhost:7001/Login.html

There's more...

Read more about:


Documentation is available at
http://e-docs.bea.com/wls/docs61

Copyright © 2001 BEA Systems, Inc. All Rights Reserved.