In your client code, reference the EJB component by using an @EJB annotation or by looking up the JNDI name as defined in the ejb-jar.xml file.
For more information about naming and lookups, see Accessing the Naming Context.
Define the @EJB annotations or the ejb-ref elements in the application-client.xml file. Define the corresponding ejb-ref elements in the sun-application-client.xml file.
For more information on the sun-application-client.xml file, see The sun-application-client.xml file in Oracle GlassFish Server 3.0.1 Application Deployment Guide. 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 the Oracle GlassFish Server 3.0.1 Application Deployment Guide. To get the client JAR file, use the ----retrieve option of the asadmin deploy command.
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 Oracle GlassFish Server 3.0.1 Reference Manual.
Ensure that the client JAR file includes the following files:
A Java class to access the bean.
application-client.xml - (optional) Java EE application client deployment descriptor.
sun-application-client.xml - (optional) GlassFish Server specific client deployment descriptor. For information on the sun-application-client.xml file, see The sun-application-client.xml file in Oracle GlassFish Server 3.0.1 Application Deployment Guide.
The MANIFEST.MF file. This file contains a reference to the main class, which states the complete package prefix and class name of the Java client.
Prepare the client machine. This step is not needed for Java Web Start.
If you are using the appclient script, package the GlassFish Server system files required to launch application clients on remote systems using the package-appclient script, then retrieve the application client itself using the asadmin get-client-stubs command.
Define the target-server element’s address and port attributes to reference the remote server machine and its ORB port. See target-server in Oracle GlassFish Server 3.0.1 Application Deployment Guide.
Use the -targetserver option of the appclient script to reference the remote server machine and its ORB port. For more information, see Running an Application Client Using the appclient Script.
To determine the ORB port on the remote server, use the asadmin get command. For example:
asadmin --host rmtsrv get server-config.iiop-service.iiop-listener.iiop-listener1.port
For more information about the asadmin get command, see the Oracle GlassFish Server 3.0.1 Reference Manual.
Run the application client.