In your client code, instantiate the InitialContext using the default (no argument) constructor:
InitialContext ctx = new InitialContext();
It is not necessary to explicitly instantiate a naming context that points to the CosNaming service.
In your client code, look up the home object by specifying the JNDI name of the home object as specified in the ejb-jar.xml file.
Object ref = ctx.lookup("java:comp/env/ejb-ref-name"); BeanAHome = (BeanAHome)PortableRemoteObject.narrow(ref,BeanAHome.class);
For more information about naming and lookups, see Accessing the Naming Context.
Define the ejb-ref elements in the application-client.xml file and the corresponding sun-application-client.xml file.
For more information on the sun-application-client.xml file, see The sun-application-client.xml file. For a general explanation of how to map JNDI names using reference elements, see Mapping References.
Deploy the application client and EJB component together in an application.
For more information on deployment, see Tools for Deployment. To get the client JAR file, use the --retrieve option.
To retrieve the stubs and ties whether or not you requested their generation during deployment, use the asadmin get-client-stubs command. For details, see the Sun Java System Application Server Platform Edition 8.1 2005Q2 Update 2 Reference Manual.
Ensure that the client JAR file includes the following files:
a Java class to access the bean
application-client.xml - J2EE 1.4 application client deployment descriptor.
sun-application-client.xml - Application Server specific client deployment descriptor. For information on the sun-application-client.xml file, see The sun-application-client.xml file.
The MANIFEST.MF file. This file contains the main class, which states the complete package prefix and class name of the Java client.
You can package the application client using the package-appclient script. This is optional. See Packaging an Application Client Using the ACC.
Copy the following JAR files to the client machine and include them in the classpath on the client side:
appserv-rt.jar - available at install-dir/lib
j2ee.jar - available at install-dir/lib
The client JAR file
Define the target-server element’s address attribute to reference the remote server machine.
Define the target-server element’s port attribute to reference the ORB port on the remote server.
This information can be obtained from the domain.xml file on the remote system. For more information on domain.xml file, see the Sun Java System Application Server Platform Edition 8.1 2005Q2 Update 2 Administration Reference.
For more information about the sun-acc.xml file, see The sun-acc.xml File.
Run the application client. See Running an Application Client Using the ACC.