Sun GlassFish Enterprise Server v3 Prelude Application Deployment Guide

Overview of Assembly and Deployment

Application assembly (also known as packaging) is the process of combining discrete components into a single unit that can be deployed to a Java-EE-compliant application server. This section covers the following topics:

About Modules

A module is a collection of one or more components that execute in the same container type (for example, web or EJB) with annotations or deployment descriptors of that type. In the Java EE modules, one descriptor is Java EE standard, the other is optional and Enterprise Server specific. Annotations can be used instead of Java EE standard descriptors.

Types of modules are as follows:

Package definitions must be used in the source code of all modules so the class loader can properly locate the classes after the modules have been deployed.

Because the information in a deployment descriptor is declarative, it can be changed without requiring modifications to source code. At run time, the Java EE server reads this information and acts accordingly.

EJB JAR and Web modules can be deployed separately, outside of any application. EJB components are assembled in a JAR file with annotations or ejb-jar.xml and sun-ejb-jar.xml deployment descriptors. Web components are assembled in a WAR file with annotations or web.xml and sun-web.xml deployment descriptors.

Java EE Standard Annotation

The Enterprise Server supports modules annotated according to the following specifications:

The following annotation and deployment descriptor combinations are supported:

Java EE Standard Descriptors

Java EE standard deployment descriptors are described in the Java EE specification, v5. You can find the specification at http://java.sun.com/products/. Information about the XML schemas that define Java EE standard deployment descriptors is available at http://java.sun.com/xml/ns/javaee/.

Enterprise Server Descriptors

The Enterprise Server uses additional, optional deployment descriptors for configuring features specific to the Enterprise Server.

For complete descriptions of these files, see Appendix A, Deployment Descriptor Files.

Naming Standards

Names of applications and individually deployed EJB JAR and WAR modules must be unique within an Enterprise Server domain. Modules of the same type within an application must have unique names.

If you do not explicitly specify a name, the default name is the first portion of the file name (without the .war or .jar extension). Modules of different types can have the same name within an application, because the directories holding the individual modules are named with _jar and _war suffixes. This is the case when you use the Administration Console or the asadmin command. If you use the asadmin deploy command to deploy a directory, your directory structure must follow this same convention. See Directory Deployment and Tools for Deployment.

You can specify a name in one of these ways:

Make sure your package and file names do not contain spaces or characters that are illegal for your operating system.

Using a Java package-like naming scheme is recommended for module filenames, module names as found in the <module-name> portion of the ejb-jar.xml files, and EJB names as found in the <ejb-name> portion of the ejb-jar.xml files. The use of this package-like naming scheme ensures that name collisions do not occur. The benefits of this naming practice apply not only to the Enterprise Server, but to other Java EE application servers as well.

JNDI lookup names for EJB components must also be unique.

Directory Structure

When you deploy a module, the module is expanded from the WAR or JAR file to an open directory structure. The directories are named with _jar and _war suffixes. If you use the asadmin deploy command to deploy a directory, your directory structure must follow this same convention; see Directory Deployment. Module directory structures follow the structure outlined in the Java EE specification.