Prior to exercising this sample, the sample Packaging Sample "C" must be deployed. To become familiar with deploying an RMI/IIOP-based Java application client, it is recommended that you first read the section about Enabling RMI/IIOP in the "Getting Started" file.
If you have already installed this sample, go to Running the RMI/IIOP Client section to access the sample.
This sample demonstrate concurrent access to the same EJB from RMI/IIOP and servlet clients.
An RMI/IIOP client application (ModuleClient) calls methods of the EJB ModuleLibrary The EJB in turn accesses methods of classes in library.jar. This sample demonstrates the following features:
The rest of the document contains the following sections:
Assembling the RMI/IIOP Client
Although in practice, you will most likely script the following client application
deployment steps, the manual steps are described below in order to
provide you with a sense of deploying an RMI/IIOP client. Since manual steps
such as setting CLASSPATH variables and such are prone to error,
please review each step carefully.
As you review the sample build facility described in Compiling and Assembling
the Application, you'll note the install_client
target that automates
steps 1, 5 and 6. Since the other steps are one time configuration changes,
using the "build install_client"
command will prove to
be a great time
saver for local client redeployments.
1.Compile Client Source File
2.Setup Client Directories
3.Install RMI/IIOP Client Support
4.Set the Client Environment Variables
5.Copy Client Application Main Class
6.Copy EJB Interfaces and iPlanet-Specific Stubs
7.Check Your Client Setup
1. Compile Client Source File
To compile the application sources simply execute "build compile"
under the application's src/ directory.
2. Setup Client Directories
Establish a directory on your client system to support the client application
class files, the EJB home and remote interface classes as well as the
RMI/IIOP stub classes. The specific directory names shown below are not required
and may be changed to suit your environment.
For example, on UNIX, it could be:
/opt/rmi-client/
For example, on Windows, it could be:
d:\rmi-client\
3. Install RMI/IIOP Client Support
If you are planning to run the Java application client on a machine other than the one on which the application server resides, refer to the RMI/IIOP chapter of the Developer's Guide for details on the configuration of the remote client environment.
4. Set the Client Environment Variables
Ensure that the PATH and CLASSPATH variables reference the appropriate JDK, javax.jar and iasclient.jar files.
Testing RMI/IIOP Client Access to EJBs on Same System
If you are experimenting with RMI/IIOP client access using a client that
is on the same machine as the application server, you can take a shortcut to
setting up the PATH and CLASSPATH variables. Simply reference the existing,
pre-installed copies of the javax.jar, iasclient.jar and usr/java/bin/.
For example, to test RMI/IIOP access locally, set the CLASSPATH variable as
follows (since the Windows System PATH environment variable
already contains usr/java/bin/ of the bundled JDK, there is no need to set this
again on Windows):
Windows:
set CLASSPATH=d:\iplanet\ias6\ias\lib\java\javax.jar;d:\iplanet\ias6\ias\classes\java\iasclient.jar;%CLASSPATH%
You could set the Windows System CLASSPATH to avoid having to manually set the variable.
UNIX:
export CLASSPATH=/usr/iplanet/ias6/ias/classes/java/javax.jar:/usr/iplanet/ias6/ias/classes/java/iasclient.jar:$CLASSPATH
On UNIX, you will also need to modify the PATH to include the bundled JDK directory:
export PATH=/usr/iplanet/ias6/ias/usr/java/bin:$PATH
Testing RMI/IIOP Client Access to EJBs from a Remote System
If you are using a remote client system, then follow these steps to establish
the appropriate PATH and CLASSPATH settings.
UNIX
Set your PATH environment variable to include the appropriate Java 2 bin/ directory:
export PATH=<Java 2 install>/usr/java/bin:$PATH
Set your CLASSPATH to include the standard Java Extension classes and the iPlanet RMI/IIOP client support JAR:
export CLASSPATH=/opt/rmi-client/iasclient.jar:/opt/rmi-client/javax.jar:$CLASSPATH
Doublecheck the CLASSPATH to ensure that it is set correctly (your CLASSPATH may vary from the one shown below).
echo $CLASSPATH
/opt/rmi-client/iasclient.jar:/opt/rmi-client/javax.jar:
Windows
Set your PATH environment variable to include the appropriate Java 2 bin/ directory:
set PATH=<Java 2 install>\usr\java\bin;%PATH%
Set your CLASSPATH to include the standard Java Extension classes (javax.jar) and the iPlanet client support JAR (iasclient.jar).
set CLASSPATH=d:\rmi-client\javax.jar;d:\rmi-client\iasclient.jar;%CLASSPATH%
5. Copy Client Application Main Class
Copy the ModuleClient.class file from the compile location to the client application
directory.
Copy ModuleClient.class to...
UNIX: /opt/rmi-client/samples/pkgingD/client
Windows: d:\rmi-client\samples\ pkgingD\client
Set your client's CLASSPATH to include the ModuleLibrary client directory path:
UNIX:
export CLASSPATH=/opt/rmi-client:$CLASSPATH
Windows:
set CLASSPATH=d:\rmi-client;%CLASSPATH%
This setting will enable both the application main class as well as the samples specific EJB interfaces and stubs to be accessed at run time.
6. Copy EJB Interfaces and Application Server-Specific Stubs
From the ias-samples/pkging/components/build/classes/samples/pkging/ejb build
area on the application server, copy the following files to the package
location (samples/pkging) under the client application directory.
ModuleLibrary.class
ModuleLibraryHome.class
EJB-Specific iPlanet Client Stubs:
_ModuleLibrary_Stub.class
_ModuleLibraryHome_Stub.class
7. Check Your Client Setup
Go to the rmi-client/ directory and navigate to the samples/pkgingD/client directory. You should see the following files:
ModuleClient.class
Go to the rmi-client/ directory and navigate to the samples/pkging/ejb?
ModuleLibrary.class
ModuleLibraryHome.class
_ModuleLibraryHome_Stub.class
_ModuleLibrary_Stub.class
Review Configuration
Before running the sample, first double check your work thus far by ensuring that:
Executing the Java Application Client
From the rmi-client/ directory, execute the following command:
java samples.pkgingD.client.ModuleClient <hostname> <port>
For example,
java samples.pkgingD.client.ModuleClient localhost 9010
Where:
<hostname> is the host name of the application server.
<port> is the IIOP port number of the RMI-IIOP bridge or cxs process on the iAS server.
If you encounter problems when running the application, review the General Troubleshooting section to learn how to view logs files and to troubleshoot RMI/IIOP configuration issues.
Copyright
(c) 2001 Sun Microsystems, Inc. All rights reserved.