RMI/IIOP Access to EJBs

# RMI/IIOP Access to EJBs

## Table of Contents

- Overview

- Compiling and Assembling the Sample Application

- Deploying the Sample Application

- Running the Sample Application

Overview

This sample is based on the Currency Converter EJB sample included in Sun One Application Server 7.0. It demonstrates RMI/IIOP-based access to a simple stateless session bean. This sample will help you understand how to enable concurrent access to the EJBs from web-based servlets/JSPs running on Sun ONE Web Server.

Compiling and Assembling the Sample Application

This section contains instructions for compiling and assembling the sample application.
(1) Include the following in the <webserver_instance_root>/config/server.policy file:
grant {
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.loader";
};
(2) Open the build.xml file and specify the correct Sun ONE Application Server 7.0 machine name and iiop-listener port number for creating the external resource.
(3) Make sure you copy the following two jar files from Sun ONE Application Server 7.0 to the <webserver_install_root>/plugins/java/samples/webapps/rmi-iiop/src/docroot/WEB-INF/lib directory:
(a) rmi-simpleClient.jar
(b) appserv-ext.jar
NOTE:
Make sure the following two samples are deployed and running in Sun ONE Application Server 7.0:
(a) Stateless Simple EJB Converter sample application (see <Application server samples directory>/ejb/stateless/converter/docs/index.html).
(b) RMI/IIOP Access to EJBs sample (see <Application server samples directory>/rmi-iiop/simple/docs/index.html).
rmi-simpleClient.jar should be available under the Sun ONE Application Server 7.0 applications deployment directory:
<ApplicationServer7.0_install_dir>/domains/<domain name>/<server name>/applications/j2ee-apps/<rmi-simple sample directory>.
For example:
<ApplicationServer7.0_install_dir>/domains/domain1/server1/applications/j2ee-apps/rmi-simple_1
appserv-ext.jar should be available under the Sun One Application Server 7.0 lib directory:
<ApplicationServer7.0_install_dir>/lib
The rmi-simpleClient.jar contains more files than absolutely necessary for running this sample. So you can use the rmi-simpleClient.jar without any modification, or you can open the rmi-simpleClient.jar, make sure the following necessary classes are present, and remove the remaining items.
samples/rmi/simple/ejb/Converter.class - Remote Interface
samples/rmi/simple/ejb/ConverterHome.class - Home Interface
samples/rmi/simple/ejb/ConverterBean.class - Bean Class
samples/rmi/simple/ejb/_Converter_Stub.class - Remote Stub
samples/rmi/simple/ejb/_ConverterHome_Stub.class - Home Stub
samples/rmi/simple/client/ConverterClient.class - Client Application Main Class
(3) Open the server.xml file of the web server instance.
Add the following to the classpathsuffix:
<install_root>/plugins/java/samples/webapps/rmi-iiop/src/docroot/WEB-INF/lib/rmi-simpleClient.jar
<install_root>/plugins/java/samples/webapps/rmi-iiop/src/docroot/WEB-INF/lib/appserv-ext.jar
For example, check the following sample JAVA element (/ws61 is the <install_root>):

       Change it from this:

      <JAVA javahome="/ws61/bin/https/jdk" serverclasspath="/ws61/bin/https/jar/webserv-rt.jar:
      ${java.home}/lib/tools.jar:/ws61/bin/https/jar/webserv-ext.jar:/ws61/bin/https/jar/webserv-jstl.jar:
      /ws61/bin/https/jar/ktsearch.jar" classpathsuffix="" envclasspathignored="on" debug="false"
      debugoptions="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" dynamicreloadinterval="2">
      ........
      ........
      </JAVA>

      to this:

      <JAVA javahome="/ws61/bin/https/jdk" serverclasspath="/ws61/bin/https/jar/webserv-rt.jar:
      ${java.home}/lib/tools.jar:/ws61/bin/https/jar/webserv-ext.jar:/ws61/bin/https/jar/webserv-jstl.jar:
      /ws61/bin/https/jar/ktsearch.jar" classpathsuffix="/ws61/plugins/java/samples/webapps/rmi-iiop/src/docroot/WEB-INF/lib/rmi-simpleClient.jar:
      /ws61/plugins/java/samples/webapps/rmi-iiop/src/docroot/WEB-INF/lib/appserv-ext.jar" envclasspathignored="on" debug="false"
      debugoptions="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" dynamicreloadinterval="2">
      ........
      ........
      </JAVA>

(4) Restart the web server instance.
(5) Go to <install_root>/plugins/java/samples/webapps/rmi-iiop/src/ and e xecute the ant command.

The default target 'default' will be executed to build the WAR file.

Deploying the Sample Application
To deploy the sample application:
1. Go to the src directory of the sample:

<install_root>/plugins/java/samples/webapps/rmi-iiop/src

2. Run ant using the deploy task:
ant deploy

Verifying Deployment

As an optional step, you can verify that the application has been registered. Otherwise, proceed directly to Running the Sample Application.

> - Go to the src directory of the sample:
>   <install_root>/plugins/java/samples/webapps/rmi-iiop/src
> - Run ant using the deploy task:
>   ant list_apps
>   You will see the rmi-simple module displayed as one of the listed components.

Undeploying the Application

> 1. Go to <install_root>/plugins/java/samples/webapps/rmi-iiop/src
> 2. Execute the following:
>    ant undeploy

Running the Sample Application

You can run the application through the following URL:

> http://<Web_Server_hostname>:<port>/rmi-simple/index.jsp

## Copyright © 2003 Sun Microsystems, Inc. All rights reserved.