|Prev | Next||J2EETM Developer's Guide
program locates an enterprise bean with the following call:
TheObject objref = initial.lookup("java:comp/env/ejb/SimpleConverter");
ejb/SimpleConverterstring is the name by which the
J2EEClientcode refers to the enterprise bean. This name does not have to be identical to the JNDI name of the enterprise bean in the deployed application. For example, the enterprise bean's JNDI name might be
MyConverter. In this case, you would map
ejb/SimpleConverter,the name coded in the client, to
MyConverter, the JNDI name of the enterprise bean. (A later section "Specifying the JNDI Name", shows you how to map the names with the Application Deployment Tool.)
Although this mapping adds a level of indirection, it provides a major benefit to distributed applications: Clients may use different names to refer to the same enterprise bean. The
J2EEClient code, for example, uses the
SimpleConverter name, but another client might refer to the same bean as
CurrencyConverter. Even if you changed the bean's JNDI name (
MyConverter) on the server, you wouldn't have to change the client's source code. But you would have to map the names again and re-deploy the application.
A stand-alone Java application client (such as
ConverterClient), also locates an enterprise bean by calling the JNDI
lookup method. However, the name coded in the stand-alone client must be identical to the bean's JNDI name on the server. You cannot map the two names in the Application Deployment Tool.
. The application contains the session bean documented in the Getting Started chapter. The source code required by the application resides in the
doc/guides/ejb/examples/convertersubdirectory. Before stepping through the instructions in the next section, you should prepare the application:
Introduction Dialog Box:
a. Read this explanatory text for an overview of the wizard's features.
b. Click Next.General Dialog Box:
a. Click the Add button next to the Contents text area.
b. In the dialog box titled "Add files to JAR," choose the directory containing the
examples/converter). You may either type the directory name in the Root Directory field or locate it by clicking Browse.
c. Select the
J2EEClient.classfile from the text area and click Add.
d. Click OK.
e. In the Display Name field, enter
f. Click Next.Enterprise Bean References Dialog Box:
a. Click Add.
b. In the Coded Name column enter
c. In the Type column select
d. In the Home column enter
e. In the Remote column enter
f. Click Finish.
ConverterAppapplication, the JNDI name of the
MyConverter. But the
J2EEClientprogram refers to the same enterprise bean as
SimpleConverter. Therefore, you must map the
1. In the tree view, select the
2. In the JNDI Names tabbed pane perform these steps:
a. Verify that the
ConverterBeancomponent has the
b. For the
MyConverterfor the JNDI name.
2. In the first dialog box, select the checkbox labelled "Return Client Jar."
3. In the text field that appears, enter the full path name for the file
J2EEClientprogram , enter this command:
Therunclient -client ConverterApp.ear -name MyConverterClient
ConverterApp.earfile contains the J2EE application. The
MyConverterClientoption is the display name of the J2EE application client component.
The client container pops open a login window. In the User Name field enter
guest and in the Password field enter
guest123. (These entries are the default values specified in the
If the J2EE application client does not reside on the same host as the J2EE server, you should follow these steps:
1. Copy the
ConverterAppClient.jar file to the client host machine. Created during deployment, the
ConverterAppClient.jar file contains stub classes that enable remote connectivity.
2. Copy the
ConverterApp.ear file to the client host machine.
3. Set the APPCPATH environment variable to the fully qualified name of the .jar file. In the following example, the fully qualified name is
UNIX, Bourne and Korn shells:setenv APPCPATH /user/duke/ConverterAppClient.jar
Windows:APPCPATH=/user/duke/ConverterAppClient.jar export APPCPATH
4. Set the VMARGS environment variable to theset APPCPATH=\user\duke\ConverterAppClient.jar
-Dorg.omg.CORBA.ORBInitialHostoption. In the following example, the option points to the remote host named buzz, where the J2EE server is running:
UNIX, Bourne and Korn shells:setenv VMARGS -Dorg.omg.CORBA.ORBInitialHost=buzz
Windows:VMARGS="-Dorg.omg.CORBA.ORBInitialHost=buzz" export VMARGS
5. Run theset VMARGS=-Dorg.omg.CORBA.ORBInitialHost=buzz
runclient -client ConverterApp.ear -name MyConverterClient
TOC | Index