Sun GlassFish Enterprise Server v2.1.1 Developer's Guide

ProcedureTo Access a JMS Resource From an Application Client

  1. Create a JMS client.

    For detailed instructions on developing a JMS client, see “Chapter 33: The Java Message Service API” in the Java EE 5 Tutorial.

  2. Next, configure a JMS resource on the Enterprise Server.

    For information on configuring JMS resources, see Creating JMS Resources: Destinations and Connection Factories.

  3. Define the @Resource or @Resources annotations or the resource-ref elements in the application-client.xml file. Define the corresponding resource-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 GlassFish Enterprise Server v2.1.1 Application Deployment Guide. For a general explanation of how to map JNDI names using reference elements, see Mapping References.

  4. Ensure that the client JAR file includes the following files:

    • A Java class to access the resource.

    • 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) Enterprise Server specific client deployment descriptor. For information on the sun-application-client.xml file, see The sun-application-client.xml file in Sun GlassFish Enterprise Server v2.1.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.

  5. Prepare the client machine. This step is not needed for Java Web Start.

    If you are using the appclient script, either package the application client to run on a remote client system using the package-appclient script, or copy the following JAR files to the client machine manually and include them in the classpath on the client side:

    • appserv-rt.jar - available at as-install/lib

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

    • imqjmsra.jar - available at as-install/lib/install/aplications/jmsra

    • The client JAR file

    For more information, see Using the package-appclient Script.

  6. Run the application client.

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