RMI/IIOP Access to EJBs

  Samples Index


RMI/IIOP Access to EJBs



Table of Contents


Overview

This sample is based on the Currency Converter EJB sample included in Sun's J2EE Developer's Guide. It demonstrates RMI/IIOP-based access to a simple stateless session bean. This sample will help you to understand how to enable concurrent access to the EJBs via both RMI/IIOP-based Java clients and web-based servlets/JSPs clients. RMI/IIOP-based Java clients are executed inside Application Client Container (ACC) or outside ACC, while the web-based servlets/JSPs clients are executed in Web Container as shown in Figure 1. The section Running the Sample Application demonstrates how to run application client without ACC or with ACC.

Figure 1    Access to EJBs via Java and Web Clients


Compiling and Assembling the Sample Application

This procedure describes how to compile and assemble the sample using a Command Line Interface (CLI).

Deploying the Sample Application

Select CLI or GUI to deploy the application using the EAR file assembled in previous section.

Command Line based Deployment

An alternative way to deploy is to use Application Server Administration Tool. It can also be used to verify the registration, i.e.


GUI Based Deployment

Since a pre-built Enterprise Archive (.ear) file for the sample application is included with the application server, you can use the Admin GUI to quickly read in the .ear file and deploy it to the application server.

  1. Start the admin server if it is not already started. Here are the commands for each platform:
    1. Unix - Execute the <install_dir>/bin/asadmin start-domain domain1 command.
    2. Windows - Click "Start->Programs->Sun Microsystems->J2EE 1.4 SDK->Start Default Server"  command.
  2. Open the .ear file.
    1. Start Admin GUI, by entering URL  http://localhost:<admin.port>/asadmin   in browser. See replacing "localhost" and <admin.port> note here to determine correct values to use for your environment
    2. You are prompted to supply the user name and password of the application server. Enter correct values for your installed application server for "User Name:"  and "Password:" input fields, then click on the "Login" button.
    3. In the left-hand frame, click Applications-->Enterprise Applications  icon in the tree.
    4. In the right-hand frame, click on the "Deploy..."  button.
    5. Choose the file to be deployed by clicking on the "Browse..."  button, and navigate to select component to deploy (rmi-simple.ear).
    6. In the browse dialog, click on the "OK"  button.
    7. In the right-hand frame, click on the "Next"  button.
    8. In the right-hand frame, click on the "OK"  button. (Optionally fill in remaining values for application to be deployed)
    9. In the left hand pane, you will see the newly deployed module's icon in the tree. In the right hand pane you will also see the component listed as deployed.

Running the Sample Application

1.   Web-based client.

The Servlets/JSPs client will be run via a browser.

2.   Local RMI/IIOP-based client with ACC.

The Java client will be run on the same machine where the Application Server is running.

3.   Remote RMI/IIOP-based client with ACC.

The Java client will be run on the different machine where the Application Server is running.

4.   Local or remote RMI/IIOP-based client without ACC.

The java client is executed without using the interface of Application Client Container. By default it executes on the local machine. The client application runs from the command line, i.e. where As a complete example for the command, it looks like the following for this sample,

On Solaris:

On Windows:

After that, you should see the last two lines from screen as the result of converting 100 units of USD to Yen, and 100 Yen to Euro.

NOTE: To run the client from a remote machine you will need to pass
org.omg.CORBA.ORBInitialHost=<remote machine hostname> and org.omg.CORBA.ORBInitialPort=<ORB port of the remote machine> for example:

        java -Dorg.omg.CORBA.ORBInitialHost=<hostname> -Dorg.omg.CORBA.ORBInitialPort=<port>
     -classpath ./rmi-simpleClient.jar:/tmp/SUNWappserver/lib/appserv-rt.jar:/tmp/SUNWappserver/lib/j2ee.jar
     samples.rmi.simple.client.ConverterClient rmiconverter

Please replace <hostname> and <port> with actual remote machine name and ORB port (usually 3700).

Troubleshooting

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