Contained WithinFind More DocumentationFeatured Support Resources | Descargar este libro en PDF (1095 KB)
Chapter 1 Assembling and Deploying ApplicationsThis chapter describes Sun JavaTM System Enterprise Server modules and how these modules are assembled. This chapter also describes tools for assembly and deployment. The Enterprise Server modules include Java Platform, Enterprise Edition (Java EE platform) standard features and Enterprise Server specific features. Only Enterprise Server specific features are described in detail in this chapter. The following topics are presented in this chapter: Note – For GlassFish v3 Prelude, EJB modules are not supported unless the optional EJB container add-on component is downloaded from the Update Tool. Only stateless session beans with local interfaces and entity beans that use the Java Persistence API are supported. Stateful, message-driven, and EJB 2.0 and 2.1 entity beans are not supported. Remote interfaces and remote business interfaces for any of the bean types are not supported. The sun-ejb-jar.xml elements related to these features are ignored. Web services are not supported unless the optional Metro (JSR 109) add-on component is downloaded from the Update Tool. Without the Metro component, a servlet or EJB module cannot be a web service endpoint, and the sun-web.xml and sun-ejb-jar.xml elements related to web services are ignored. For information about the Update Tool, see the Sun GlassFish Enterprise Server v3 Prelude Installation Guide. Overview of Assembly and DeploymentApplication 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 ModulesA 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 AnnotationThe Enterprise Server supports modules annotated according to the following specifications:
The following annotation and deployment descriptor combinations are supported:
Java EE Standard DescriptorsJava 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 DescriptorsThe 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 StandardsNames 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 StructureWhen 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. Assembling Modules and ApplicationsAssembling (or packaging) modules and applications in Enterprise Server conforms to all of the customary Java-EE-defined specifications. The only difference is that when you assemble in Enterprise Server, you can include optional Enterprise Server specific deployment descriptors that enhance the functionality of the Enterprise Server. For example, when you assemble an EJB JAR module, you annotate or create two deployment descriptor files with these names: ejb-jar.xml and sun-ejb-jar.xml. For more information about sun-ejb-jar.xml, see Appendix A, Deployment Descriptor Files. The Enterprise Server provides these tools for assembling and verifying a module or an application: The NetBeans IDEYou can use the NetBeansTM Integrated Development Environment (IDE), or another IDE, to assemble Java EE applications and modules. The GlassFish edition of the Enterprise Server is bundled with the NetBeans 6.1 IDE. For more information about using the NetBeans IDE, see http://www.netbeans.org. Deploying Modules and ApplicationsThis section describes the different ways to deploy Java EE modules to the Enterprise Server. It covers the following topics: Deployment ErrorsIf an error occurs during deployment, the module is not deployed. This prevents a partial deployment that could leave the server in an inconsistent state. In addition, certain warning conditions allow a module to be deployed but return a warning message to the deployment client. The Deployment Life CycleAfter installing the Enterprise Server and starting a domain, you can deploy (install) Java EE modules. During deployment and as the application is changed, a module can go through the following stages:
Deployment for DevelopmentThis section covers the following topics related to deployment for development: Note – You can overwrite a previously deployed module by using the asadmin redeploy command, the --force option of asadmin deploy, or the Redeploy button in the Administration Console. However, you must remove a preconfigured resource before you can update it. Dynamic DeploymentYou can deploy, redeploy, and undeploy a module without restarting the server. This is called dynamic deployment. Although primarily for developers, dynamic deployment can be used in operational environments to bring new applications and modules online without requiring a server restart. Whenever a redeployment is done, the sessions at that transit time become invalid unless you use the keepSessions=true property of the asadmin redeploy command. For example:
For details, see the Sun GlassFish Enterprise Server v3 Prelude Reference Manual. Keep Sessions is also a checkbox option when you redeploy using the Administration Console. For details, click the Help button in the Administration Console. Disabling a Deployed Application or ModuleYou can disable a deployed module without removing it from the server. Disabling a module makes it inaccessible to clients. To disable a module using the asadmin disable command, see the Sun GlassFish Enterprise Server v3 Prelude Reference Manual.
|
javac -cp javaee.jar -d domain-dir/autodeploy MyWS.java |
For more information about JSR 181, see http://jcp.org/en/jsr/detail?id=181. For more information about autodeployment, see Automatic Deployment.
The Sun-specific deployment descriptor files sun-web.xml and sun-ejb-jar.xml provide optional web service enhancements in their webservice-endpoint and webservice-description elements.
For more information about web services, see JSR 181 and Chapter 5, Developing Web Services, in Sun GlassFish Enterprise Server v3 Prelude Developer’s Guide.
You deploy a WAR module as described in Tools for Deployment. If you do not specify a context root, the default is the name of the WAR file without the extension.
If a web application accesses a DataSource that is not specified in a resource-ref in sun-web.xml, or there is no sun-web.xml file, the resource-ref-name defined in web.xml is used. A warning message is logged recording the JNDI name used to look up the resource.
You can precompile JSP files during deployment by checking the appropriate box in the Administration Console, or by using the --precompilejsp option of the asadmin deploy command.
You can keep the generated source for JSP files by adding the keepgenerated flag to the jsp-config element in sun-web.xml. For example:
<sun-web-app>
...
<jsp-config>
<property name=keepgenerated value=true />
</jsp-config>
</sun-web-app>
If you include this property when you deploy the WAR module, the generated source is kept in domain-dir/generated/jsp/module-name.
For more information about JSP precompilation, see jsp-config.
If you deploy a web application and don't specify any assigned virtual servers, the web application is assigned to all currently defined virtual servers. If you then create additional virtual servers and want to assign existing web applications to them, you must redeploy the web applications. For more information about virtual servers, see virtual-server in Sun GlassFish Enterprise Server v3 Prelude Administration Reference.
Whenever a redeployment is done, the sessions at that transit time become invalid unless you use the keepSessions=true property of the asadmin redeploy command. For example:
asadmin redeploy --properties keepSessions=true --name hello.war |
For details, see the Sun GlassFish Enterprise Server v3 Prelude Reference Manual.
Keep Sessions is also a checkbox option when you redeploy using the Administration Console. For details, click the Help button in the Administration Console.
Web module context roots must be unique within the server.
For GlassFish v3 Prelude, EJB modules are not supported unless the optional EJB container add-on component is downloaded from the Update Tool. Only stateless session beans with local interfaces and entity beans that use the Java Persistence API are supported. Stateful, message-driven, and EJB 2.0 and 2.1 entity beans are not supported. Remote interfaces and remote business interfaces for any of the bean types are not supported. The sun-ejb-jar.xml elements related to these features are ignored.
For information about the Update Tool, see the Sun GlassFish Enterprise Server v3 Prelude Installation Guide.
You deploy an EJB JAR module as described in Tools for Deployment.
If no JNDI name for the EJB JAR module is specified in the jndi-name element immediately under the ejb element in sun-ejb-jar.xml, or there is no sun-ejb-jar.xml file, a default, non-clashing JNDI name is derived. A warning message is logged recording the JNDI name used to look up the EJB JAR module.
When Java EE applications and modules use shared framework classes (such as utility classes and libraries) the classes can be put in the path for the Common Classloader or an application-specific class loader rather than in an application or module. If you assemble a large, shared library into every module that uses it, the result is a huge file that takes too long to register with the server. In addition, several versions of the same class could exist in different classloaders, which is a waste of resources. For more information, see Chapter 2, Class Loaders, in Sun GlassFish Enterprise Server v3 Prelude Developer’s Guide.