Sun Java System Application Server Platform Edition 9 Developer's Guide

ProcedureTo Access an EJB Component From an Application Client

  1. 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 annotations in application clients, see section 9.4 of the Java EE 5 Specification.

    For more information about naming and lookups, see Accessing the Naming Context.

  2. 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 application-client.xml file, see the Java EE 5 Specification, Section EE.9.7, “Java EE Application Client XML Schema.”

    For more information on the sun-application-client.xml file, see The sun-application-client.xml file in Sun Java System Application Server Platform Edition 9 Application Deployment Guide. For a general explanation of how to map JNDI names using reference elements, see Mapping References.

  3. Deploy the application client and EJB component together in an application.

    For more information on deployment, see the Sun Java System Application Server Platform Edition 9 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 Sun Java System Application Server Platform Edition 9 Reference Manual.

  4. 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. For information on the application-client.xml file, see the Java EE 5 Specification, Section EE.9.7, “Java EE Application Client XML Schema.”

    • sun-application-client.xml - (optional) Application Server specific client deployment descriptor. For information on the sun-application-client.xml file, see The sun-application-client.xml file in Sun Java System Application Server Platform Edition 9 Application Deployment Guide.

    • The MANIFEST.MF file. This file contains the main class, which states the complete package prefix and class name of the Java client.

    If you are not using Java Web Start, you can package the application client using the package-appclient script. This is optional. See Using the package-appclient Script.

  5. If you are not using Java Web Start, 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

    • javaee.jar - available at install-dir/lib

    • The client JAR file

  6. To access EJB components that are residing in a remote system, make the following changes to the sun-acc.xml file.

    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 9 Administration Reference.

    For more information about the sun-acc.xml file, see The sun-acc.xml File in Sun Java System Application Server Platform Edition 9 Application Deployment Guide.

  7. Run the application client.

    See Using Java Web Start or Running an Application Client Using the appclient Script.