Contained WithinFind More DocumentationFeatured Support Resources | Scarica il manuale in formato PDF (2350 KB)
Chapter 3 Assembling and Deploying ApplicationsThis chapter describes Sun Java System Application Server modules and how these modules are assembled separately or together in an application. This chapter also describes classloaders and tools for assembly and deployment. The Application Server modules and applications include J2EE standard features and Application Server specific features. Only Application Server specific features are described in detail in this chapter. The following topics are presented in this chapter: Overview of Assembly and DeploymentApplication assembly (also known as packaging) is the process of combining discrete components of an application into a single unit that can be deployed to a J2EE-compliant application server. A package can be classified either as a module or as a full-fledged application. This section covers the following topics: ModulesA J2EE module is a collection of one or more J2EE components of the same container type (for example, web or EJB) with deployment descriptors of that type. One descriptor is J2EE standard, the other is Application Server specific. Types of J2EE 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 J2EE server reads this information and acts accordingly. The Application Server also supports lifecycle modules. See Chapter 10, Developing Lifecycle Listeners for more information. EJB JAR and Web modules can also be deployed separately, outside of any application, as in the following figure. EJB components are assembled in a JAR file with ejb-jar.xml and sun-ejb-jar.xml deployment descriptors. Web components are assembled in a WAR file with web.xml and sun-web.xml deployment descriptors. Both module types are deployed to the Application Server. Figure 3–1 Module assembly and deployment
ApplicationsA J2EE application is a logical collection of one or more J2EE modules tied together by application deployment descriptors. Components can be assembled at either the module or the application level. Components can also be deployed at either the module or the application level. The following diagram illustrates how components are assembled into modules and then assembled into an Application Server application and deployed. EJB components are assembled in a JAR file with ejb-jar.xml and sun-ejb-jar.xml deployment descriptors. Web components are assembled in a WAR file with web.xml and sun-web.xml deployment descriptors. An application client is assembled in a JAR file with application-client.xml and sun-application-client.xml deployment descriptors. A resource adapter is assembled in a RAR file with a ra.xml deployment descriptor. All modules are assembled in an EAR file and deployed to the Application Server. Figure 3–2 Application assembly and deployment
Each module has an Application Server deployment descriptor and a J2EE deployment descriptor. The Application Server uses the deployment descriptors to deploy the application components and to register the resources with the Application Server. An application consists of one or more modules, an optional Application Server deployment descriptor, and a required J2EE application deployment descriptor. All items are assembled, using the Java ARchive (.jar) file format, into one file with an extension of .ear. J2EE Standard DescriptorsThe J2EE platform provides assembly and deployment facilities. These facilities use WAR, JAR, and EAR files as standard packages for components and applications, and XML-based deployment descriptors for customizing parameters. J2EE standard deployment descriptors are described in the J2EE specification, v1.4. You can find the specification at http://java.sun.com/products/. To check the correctness of these deployment descriptors prior to deployment, see The Deployment Descriptor Verifier. The following table shows where to find more information about J2EE standard deployment descriptors. Table 3–1 J2EE Standard Descriptors
Sun Java System Application Server DescriptorsThe Application Server uses additional deployment descriptors for configuring features specific to the Application Server. The sun-application.xml, sun-web.xml, and sun-cmp-mappings.xml files are optional; all the others are required. To check the correctness of these deployment descriptors prior to deployment, see The Deployment Descriptor Verifier. The following table lists the Application Server deployment descriptors and their DTD files. For complete descriptions of these files, see Appendix A, Deployment Descriptor Files. Table 3–2 Sun Java System Application Server Descriptors
Naming StandardsNames of applications and individually deployed EJB JAR, WAR, and connector RAR modules must be unique within an Application Server domain. Modules of the same type within an application must have unique names. In addition, for entity beans that use CMP,.dbschema file names must be unique within an application. 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, _war and _rar suffixes. This is the case when you use the Administration Console, the asadmin command, or the deploytool to deploy an application or module. See Tools for Deployment. Make sure your package and file names do not contain spaces or characters that are illegal for your operating system. If you are writing your own JSR 88 client to deploy applications to the Application Server using the following API, the name of the application is taken from the display-name entry in the J2EE standard deployment descriptor, because there is no file name in this case. If the display-name entry is not present, the Application Server creates a temporary file name and uses that name to deploy the application. javax.enterprise.deploy.spi.DeploymentManager.distribute(Target[], InputStream, InputStream) Neither the Administration Console, the asadmin command, nor the deploytool uses this API. For more information about JSR 88, see the JSR 88 page at http://jcp.org/en/jsr/detail?id=88. Directory StructureWhen you deploy an application, the application is expanded to an open directory structure, and the directories holding the individual modules are named with _jar, _war and _rar suffixes. If you use the asadmin deploydir command to deploy a directory instead of an EAR file, your directory structure must follow this same convention. Module and application directory structures follow the structure outlined in the J2EE specification. Here is an example directory structure of a simple application containing a web module, an EJB module, and a client module.
Here is an example directory structure of an individually deployed connector module.
Runtime EnvironmentsWhether you deploy an individual module or an application, deployment affects both the file system and the server configuration. Module Runtime EnvironmentThe following figure illustrates the environment for individually deployed module-based deployment. Figure 3–3 Module runtime environment
For file system entries, modules are extracted as follows: domain-dir/applications/j2ee-modules/module-name domain-dir/generated/ejb/j2ee-modules/module-name domain-dir/generated/jsp/j2ee-modules/module-name The applications directory contains the directory structures described in Directory Structure. The generated/ejb directory contains the stubs and ties that an ACC client needs to access the module; the generated/jsp directory contains compiled JSP files. Lifecycle modules (see Chapter 10, Developing Lifecycle Listeners) are extracted as follows: domain-dir/applications/lifecycle-modules/module-name Configuration entries are added in the domain.xml file as follows: <server>
<applications>
<type-module>
...module configuration...
</type-module>
</applications>
</server>
The type of the module in domain.xml can be lifecycle, ejb, web, or connector. For details about domain.xml, see the Sun Java System Application Server Platform Edition 8.2 Administration Reference. Application Runtime EnvironmentThe following figure illustrates the environment for application-based deployment. Figure 3–4 Application runtime environment
For file system entries, applications are extracted as follows: domain-dir/applications/j2ee-apps/app-name domain-dir/generated/ejb/j2ee-apps/app-name domain-dir/generated/jsp/j2ee-apps/app-name The applications directory contains the directory structures described in Directory Structure. The generated/ejb directory contains the stubs and ties that an ACC client needs to access the module; the generated/jsp directory contains compiled JSP files. Configuration entries are added in the domain.xml file as follows: <server>
<applications>
<j2ee-application>
...application configuration...
</j2ee-application>
</applications>
</server>
For details about domain.xml, see the Sun Java System Application Server Platform Edition 8.2 Administration Reference. ClassloadersUnderstanding Application Server classloaders can help you determine where and how you can position supporting JAR and resource files for your modules and applications. In a Java Virtual Machine (JVM), the classloaders dynamically load a specific Java class file needed for resolving a dependency. For example, when an instance of java.util.Enumeration needs to be created, one of the classloaders loads the relevant class into the environment. This section includes the following topics: The Classloader HierarchyClassloaders in the Application Server runtime follow a hierarchy that is illustrated in the following figure and fully described in Table 3–3. Figure 3–5 Classloader runtime hierarchy
Table 3–3 Sun Java System Application Server Classloaders
Note that this is not a Java inheritance hierarchy, but a delegation hierarchy. In the delegation design, a class loader delegates classloading to its parent before attempting to load a class itself. A class loader parent can be either the System Classloader or another custom class loader. If the parent class loader can’t load a class, the findClass() method is called on the class loader subclass. In effect, a class loader is responsible for loading only the classes not available to the parent. The Servlet specification recommends that the Web Classloader look in the local class loader before delegating to its parent. You can make the Web Classloader follow the delegation model in the Servlet specification by setting delegate="false" in the class-loader element of the sun-web.xml file. It’s safe to do this only for a web module that does not interact with any other modules. The default value is delegate="true", which causes the Web Classloader to delegate in the same manner as the other classloaders. You must use delegate="true" for a web application that accesses EJB components or that acts as a web service client or endpoint. For details about sun-web.xml, see The sun-web.xml File. Classloader UniversesAccess to components within applications and modules installed on the server occurs within the context of isolated class loader universes, each of which has its own EJB, Web, and JSP Engine classloaders.
Note – A resource such as a file that is accessed by a servlet, JSP, or EJB component must be in a directory pointed to by the class loader’s classpath. For example, the web class loader’s classpath includes these directories: module-name/WEB-INF/classes module-name/WEB-INF/lib If a servlet accesses a resource, it must be in one of these directories or it is not loaded. Note – In iPlanet Application Server 6.x, individually deployed modules shared the same class loader. In subsequent Application Server versions, each individually deployed module has its own class loader universe. Circumventing Classloader IsolationSince each application or individually deployed module class loader universe is isolated, an application or module cannot load classes from another application or module. This prevents two similarly named classes in different applications from interfering with each other. To circumvent this limitation for libraries, utility classes, or individually deployed modules accessed by more than one application, you can include the relevant path to the required classes in one of these ways: Using the System ClassloaderTo use the System Classloader, do one of the following, then restart the server:
Using the System Classloader makes an application or module accessible to any other application or module across the domain. Using the Common ClassloaderTo use the Common Classloader, copy the JAR and ZIP files into the domain-dir/lib directory or copy the .class files into the domain-dir/lib/classes directory, then restart the server. Using the Common Classloader makes an application or module accessible to any other application or module across the domain. Using the Java Optional Package MechanismTo use the Java optional package mechanism, copy the JAR and ZIP files into the domain-dir/lib/ext directory, then restart the server. Using the Java optional package mechanism makes an application or module accessible to any other application or module across the domain. For example, this is the recommended way of adding JDBC drivers to the Application Server. For a list of the JDBC drivers currently supported by the Application Server, see the Sun Java System Application Server Platform Edition 8.2 Release Notes. For configurations of supported and other drivers, see Configurations for Specific JDBC Drivers. Packaging the Client JAR for One Application in Another ApplicationBy packaging the client JAR for one application in a second application, you allow an EJB or web component in the second application to call an EJB component in the first (dependent) application, without making either of them accessible to any other application or module. As an alternative for a production environment, you can have the Common Classloader load client JAR of the dependent application as described in Using the Common Classloader restart the server to make the dependent application accessible, and it is accessible across the domain.
|
|
Element |
Description |
|---|---|
|
A component to be deployed. |
|
|
A set of component files that match specified parameters. |
The following table describes attributes for the sun-appserv-deploy task.
Table 3–6 sun-appserv-deploy Attributes|
Attribute |
Default |
Description |
|---|---|---|
|
none |
(optional if a component or fileset subelement is present, otherwise required) The component to deploy. If this attribute refers to a file, it must be a valid archive. If this attribute refers to a directory, it must contain a valid archive in which all components have been exploded. If upload is set to false, this must be an absolute path on the server machine. |
|
|
name |
file name without extension |
(optional) The display name for the component being deployed. |
|
determined by extension |
(optional) Deprecated. |
|
|
true |
(optional) If true, the component is overwritten if it already exists on the server. If false, sun-appserv-deploy fails if the component exists. |
|
|
client stubs not saved |
(optional) The directory where client stubs are saved. This attribute is inherited by nested component elements. |
|
|
false |
(optional) If true, all JSP files found in an enterprise application (.ear) or web application (.war) are precompiled. This attribute is ignored for other component types. This attribute is inherited by nested component elements. |
|
|
false |
(optional) If true, syntax and semantics for all deployment descriptors are automatically verified for correctness. This attribute is inherited by nested component elements. |
|
|
file name without extension |
(optional) The context root for a web module (WAR file). This attribute is ignored if the component is not a WAR file. |
|
|
sun-ejb-jar.xml entry |
(optional) The name of the database vendor for which tables can be created. Allowed values are db2, mssql, oracle, derby, and sybase, case-insensitive. If not specified, the value of the database-vendor-name attribute in sun-ejb-jar.xml is used. If no value is specified, a connection is made to the resource specified by the jndi-name subelement of the cmp-resource element in the sun-ejb-jar.xml file, and the database vendor name is read. If the connection cannot be established, or if the value is not recognized, SQL-92 compliance is presumed. For details, see Generation Options. |
|
|
sun-ejb-jar.xml entry |
(optional) If true, causes database tables to be created for beans that need them. If false, does not create tables. If not specified, the value of the create-tables-at-deploy attribute in sun-ejb-jar.xml is used. For details, see Generation Options. |
|
|
sun-ejb-jar.xml entry |
(optional) If true, and if tables were automatically created when this application was last deployed, tables from the earlier deployment are dropped and fresh ones are created. If true, and if tables were not automatically created when this application was last deployed, no attempt is made to drop any tables. If tables with the same names as those that would have been automatically created are found, the deployment proceeds, but a warning indicates that tables could not be created. If false, settings of create-tables-at-deploy or drop-tables-at-undeploy in the sun-ejb-jar.xml file are overridden. For details, see Generation Options. |
|
|
sun-ejb-jar.xml entry |
(optional) If true, specifies that table names are unique within each application server domain. If not specified, the value of the use-unique-table-names property in sun-ejb-jar.xml is used. For details, see Generation Options. |
|
|
true |
(optional) If true, enables the component. |
|
|
none |
(optional) A deployment plan is a JAR file containing Sun-specific descriptors. Use this attribute when deploying an EAR file that lacks Sun-specific descriptors. |
|
|
true |
(optional) If true, the component is transferred to the server for deployment. If the component is being deployed on the local machine, set upload to false to reduce deployment time. If a directory is specified for deployment, upload must be false. |
|
|
default virtual server only |
(optional) A comma-separated list of virtual servers to be deployment targets. This attribute applies only to application (.ear) or web (.war) components and is ignored for other component types. |
|
|
admin |
(optional) The user name used when logging into the application server. |
|
|
password |
none |
(optional) Deprecated, use passwordfile instead. The password used when logging into the application server. |
|
passwordfile |
none |
(optional) File containing passwords. The password from this file is retrieved for communication with the application server. If both password and passwordfile are specified, passwordfile takes precedence. |
|
localhost |
(optional) Target server. When deploying to a remote server, use the fully qualified host name. |
|
|
4848 |
(optional) The administration port on the target server. |
|
|
see description |
(optional) The installation directory for the local Application Server installation, which is used to find the administrative classes. If not specified, the command checks to see if the asinstalldir parameter has been set. Otherwise, administrative classes must be in the system classpath. |
|
|
see description |
(optional) Deprecated. Use asinstalldir instead. |
Here is a simple application deployment script with many implied attributes:
<sun-appserv-deploy
file="${assemble}/simpleapp.ear"
passwordfile="${passwordfile}" />
Here is an equivalent script showing all the implied attributes:
<sun-appserv-deploy
file="${assemble}/simpleapp.ear"
name="simpleapp"
force="true"
precompilejsp="false"
verify="false"
upload="true"
user="admin"
passwordfile="${passwordfile}"
host="localhost"
port="4848"
asinstalldir="${asinstalldir}" />
This example deploys multiple components to the same Application Server running on a remote server:
<sun-appserv-deploy passwordfile="${passwordfile}" host="greg.sun.com"
asinstalldir="/opt/sun" >
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"
contextroot="test"/>
<component file="${assemble}/simplebean.jar"/>
</sun-appserv-deploy>
This example deploys the same components as the previous example because the three components match the fileset criteria, but note that it’s not possible to set some component-specific attributes. All component-specific attributes (name and contextroot) use their default values.
<sun-appserv-deploy passwordfile="${passwordfile}" host="greg.sun.com"
asinstalldir="/opt/sun" >
<fileset dir="${assemble}" includes="**/*.?ar" />
</sun-appserv-deploy>
Undeploys any of the following.
Enterprise application (EAR file)
Web application (WAR file)
Enterprise Java Bean (EJB-JAR file)
Enterprise connector (RAR file)
Application client
The following table describes subelements for the sun-appserv-undeploy task. These are objects upon which this task acts.
Table 3–7 sun-appserv-undeploy Subelements|
Element |
Description |
|---|---|
|
A component to be deployed. |
|
|
A set of component files that match specified parameters. |
The following table describes attributes for the sun-appserv-undeploy task.
Table 3–8 sun-appserv-undeploy Attributes|
Attribute |
Default |
Description |
|---|---|---|
|
name |
file name without extension |
(optional if a component or fileset subelement is present or the file attribute is specified, otherwise required) The display name for the component being undeployed. |
|
none |
(optional) The component to undeploy. If this attribute refers to a file, it must be a valid archive. If this attribute refers to a directory, it must contain a valid archive in which all components have been exploded. |
|
|
determined by extension |
(optional) Deprecated. |
|
|
sun-ejb-jar.xml entry |
(optional) If true, causes database tables that were automatically created when the bean(s) were last deployed to be dropped when the bean(s) are undeployed. If false, does not drop tables. If not specified, the value of the drop-tables-at-undeploy attribute in sun-ejb-jar.xml is used. For details, see Generation Options. |
|
|
false |
(optional) If true, deletes all connection pools and connector resources associated with the resource adapter being undeployed. If false, undeployment fails if any pools or resources are still associated with the resource adapter. This attribute is applicable to connectors (resource adapters) and applications with connector modules. |
|
|
admin |
(optional) The user name used when logging into the application server. |
|
|
password |
none |
(optional) Deprecated, use passwordfile instead. The password used when logging into the application server. |
|
passwordfile |
none |
(optional) File containing passwords. The password from this file is retrieved for communication with the application server. If both password and passwordfile are specified, passwordfile takes precedence. |
|
localhost |
(optional) Target server. When deploying to a remote server, use the fully qualified host name. |
|
|
4848 |
(optional) The administration port on the target server. |
|
|
see description |
(optional) The installation directory for the local Application Server installation, which is used to find the administrative classes. If not specified, the command checks to see if the asinstalldir parameter has been set. Otherwise, administrative classes must be in the system classpath. |
|
|
see description |
(optional) Deprecated. Use asinstalldir instead. |
Here is a simple application undeployment script with many implied attributes:
<sun-appserv-undeploy name="simpleapp" passwordfile="${passwordfile}" />
Here is an equivalent script showing all the implied attributes:
<sun-appserv-undeploy
name="simpleapp"
user="admin"
passwordfile="${passwordfile}"
host="localhost"
port="4848"
asinstalldir="${asinstalldir}" />
This example demonstrates using the archive files (EAR and WAR, in this case) for the undeployment, using the component name (for undeploying the EJB component in this example), and undeploying multiple components.
<sun-appserv-undeploy passwordfile="${passwordfile}">
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-undeploy>
Enables or disables the following J2EE component types that have been deployed to the Application Server.
Enterprise application (EAR file)
Web application (WAR file)
Enterprise Java Bean (EJB-JAR file)
Enterprise connector (RAR file)
Application client
You don’t need to specify the archive to enable or disable a component: only the component name is required. You can use the component archive, however, because it implies the component name.
The following table describes subelements for the sun-appserv-component task. These are objects upon which this task acts.
Table 3–9 sun-appserv-component Subelements|
Element |
Description |
|---|---|
|
A component to be deployed. |
|
|
A set of component files that match specified parameters. |
The following table describes attributes for the sun-appserv-component task.
Table 3–10 sun-appserv-component Attributes|
Attribute |
Default |
Description |
|---|---|---|
|
none |
The control command for the target application server. Valid values are enable and disable. |
|
|
name |
file name without extension |
(optional if a component or fileset subelement is present or the file attribute is specified, otherwise required) The display name for the component being enabled or disabled. |
|
none |
(optional) The component to enable or disable. If this attribute refers to a file, it must be a valid archive. If this attribute refers to a directory, it must contain a valid archive in which all components have been exploded. |
|
|
determined by extension |
(optional) Deprecated. |
|
|
admin |
(optional) The user name used when logging into the application server. |
|
|
password |
none |
(optional) Deprecated, use passwordfile instead. The password used when logging into the application server. |
|
passwordfile |
none |
(optional) File containing passwords. The password from this file is retrieved for communication with the application server. If both password and passwordfile are specified, passwordfile takes precedence. |
|
localhost |
(optional) Target server. When enabling or disabling a remote server, use the fully qualified host name. |
|
|
4848 |
(optional) The administration port on the target server. |
|
|
see description |
(optional) The installation directory for the local Application Server installation, which is used to find the administrative classes. If not specified, the command checks to see if the asinstalldir parameter has been set. Otherwise, administrative classes must be in the system classpath. |
|
|
see description |
(optional) Deprecated. Use asinstalldir instead. |
Here is a simple example of disabling a component:
<sun-appserv-component
action="disable"
name="simpleapp"
passwordfile="${passwordfile}" />
Here is a simple example of enabling a component:
<sun-appserv-component
action="enable"
name="simpleapp"
passwordfile="${passwordfile}" />
Here is an equivalent script showing all the implied attributes:
<sun-appserv-component
action="enable"
name="simpleapp"
user="admin"
passwordfile="${passwordfile}"
host="localhost"
port="4848"
asinstalldir="${asinstalldir}" />
This example demonstrates disabling multiple components using the archive files (EAR and WAR, in this case) and using the component name (for an EJB component in this example).
<sun-appserv-component action="disable" passwordfile="${passwordfile}">
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-component>
Enables arbitrary administrative commands and scripts to be executed on the Application Server. This is useful for cases where a specific Ant task hasn’t been developed or a set of related commands are in a single script.
none
The following table describes attributes for the sun-appserv-admin task.
Table 3–11 sun-appserv-admin Attributes|
Attribute |
Default |
Description |
|---|---|---|
|
none |
(exactly one of these is required: command, commandfile, or explicitcommand) The command to execute. If the user, passwordfile, host, or port attributes are also specified, they are automatically inserted into the command before execution. If any of these options are specified in the command string, the corresponding attribute values are ignored. |
|
|
none |
(exactly one of these is required: command, commandfile, or explicitcommand) Deprecated. The command script to execute. If commandfile is used, the values of all other attributes are ignored. Be sure to end the script referenced by commandfile with the exit command; if you omit exit, the Ant task might appear to hang after the command script is called. |
|
|
none |
(exactly one of these is required: command, commandfile, or explicitcommand) The exact command to execute. No command processing is done, and all other attributes are ignored. |
|
|
user |
admin |
(optional) The user name used when logging into the application server. |
|
password |
none |
(optional) Deprecated, use passwordfile instead. The password used when logging into the application server. |
|
passwordfile |
none |
(optional) File containing passwords. The password from this file is retrieved for communication with the application server. If both password and passwordfile are specified, passwordfile takes precedence. |
|
host |
localhost |
(optional) Target server. If it is a remote server, use the fully qualified host name. |
|
port |
4848 |
(optional) The administration port on the target server. |
|
see description |
(optional) The installation directory for the local Application Server installation, which is used to find the administrative classes. If not specified, the command checks to see if the asinstalldir parameter has been set. Otherwise, administrative classes must be in the system classpath. |
|
|
see description |
(optional) Deprecated. Use asinstalldir instead. |
Here is an example of executing the create-jms-dest command:
<sun-appserv-admin command="create-jms-dest --desttype topic">
Here is an example of using commandfile to execute the create-jms-dest command:
<sun-appserv-admin commandfile="create_jms_dest.txt" instance="development">
The create_jms_dest.txt file contains the following:
create-jms-dest --user admin --passwordfile "${passwordfile}" --host
localhost --port 4848 --desttype topic --target server1 simpleJmsDest
Here is an example of using explicitcommand to execute the create-jms-dest command:
<sun-appserv-admin command="create-jms-dest --user admin --passwordfile
"${passwordfile}" --host localhost --port 4848 --desttype topic
--target server1 simpleJmsDest">
Precompiles JSP source code into Application Server compatible Java code for initial invocation by Application Server. Use this task to speed up access to JSP files or to check the syntax of JSP source code. You can feed the resulting Java code to the javac task to generate class files for the JSP files.
none
The following table describes attributes for the sun-appserv-jspc task.
Table 3–12 sun-appserv-jspc Attributes|
Attribute |
Default |
Description |
|---|---|---|
|
|
The destination directory for the generated Java source files. |
|
|
|
(exactly one of these is required: srcdir or webapp) The source directory where the JSP files are located. |
|
|
|
(exactly one of these is required: srcdir or webapp) The directory containing the web application. All JSP files within the directory are recursively parsed. The base directory must have a WEB-INF subdirectory beneath it. When webapp is used, sun-appserv-jspc hands off all dependency checking to the compiler. |
|
|
2 |
(optional) The verbosity integer to be passed to the compiler. |
|
|
|
(optional) The classpath for running the JSP compiler. |
|
|
|
(optional) A reference to the JSP compiler classpath. |
|
|
/ |
(optional) The URI context of relative URI references in the JSP files. If this context does not exist, it is derived from the location of the JSP file relative to the declared or derived value of uriroot. Only pages translated from an explicitly declared JSP file are affected. |
|
|
see description |
(optional) The root directory of the web application, against which URI files are resolved. If this directory is not specified, the first JSP file is used to derive it: each parent directory of the first JSP file is searched for a WEB-INF directory, and the directory closest to the JSP file that has one is used. If no WEB-INF directory is found, the directory sun-appserv-jspc was called from is used. Only pages translated from an explicitly declared JSP file (including tag libraries) are affected. |
|
|
(optional) The destination package for the generated Java classes. |
||
|
see description |
(optional) The installation directory for the local Application Server installation, which is used to find the administrative classes. If not specified, the command checks to see if the asinstalldir parameter has been set. Otherwise, administrative classes must be in the system classpath. |
|
|
see description |
(optional) Deprecated. Use asinstalldir instead. |
The following example uses the webapp attribute to generate Java source files from JSP files. The sun-appserv-jspc task is immediately followed by a javac task, which compiles the generated Java files into class files. The classpath value in the javac task must be all on one line with no spaces.
<sun-appserv-jspc
destdir="${assemble.war}/generated"
webapp="${assemble.war}"
classpath="${assemble.war}/WEB-INF/classes"
asinstalldir="${asinstalldir}" />
<javac
srcdir="${assemble.war}/WEB-INF/generated"
destdir="${assemble.war}/WEB-INF/generated"
debug="on"
classpath="${assemble.war}/WEB-INF/classes:${asinstalldir}/lib/
appserv-rt.jar:${asinstalldir}/lib/appserv-ext.jar">
<include name="**/*.java"/>
</javac>
Enables deployed applications (EAR files) and modules (EJB JAR, RAR, and WAR files) to be updated and reloaded for fast iterative development. This task copies modified class files, XML files, and other contents of the archive files to the appropriate subdirectory of the domain-dir/applications directory, then touches the .reload file to cause dynamic reloading to occur.
This is a local task and must be executed on the same machine as the application server.
none
The following table describes attributes for the sun-appserv-update task.
Table 3–13 sun-appserv-update Attributes|
Attribute |
Default |
Description |
|---|---|---|
|
none |
The component to update, which must be a valid archive. |
|
|
domain1 |
(optional) The domain in which the application has been previously deployed. |
The following example updates the J2EE application foo.ear, which is deployed to the default domain, domain1.
<sun-appserv-update file="foo.ear"/>
Reusable subelements of the Ant tasks for the Application Server are as follows. These are objects upon which the Ant tasks act.
Specifies a J2EE component. Allows a single task to act on multiple components. The component attributes override corresponding attributes in the parent task; therefore, the parent task attributes function as default values.
none
The following table describes attributes for the component element.
Table 3–14 component Attributes|
Attribute |
Default |
Description |
|---|---|---|
|
none |
(optional if the parent task is sun-appserv-undeploy or sun-appserv-component) The target component. If this attribute refers to a file, it must be a valid archive. If this attribute refers to a directory, it must contain a valid archive in which all components have been exploded. If upload is set to false, this must be an absolute path on the server machine. |
|
|
name |
file name without extension |
(optional) The display name for the component. |
|
determined by extension |
(optional) Deprecated. |
|
|
true |
(applies to sun-appserv-deploy only, optional) If true, the component is overwritten if it already exists on the server. If false, the containing element’s operation fails if the component exists. |
|
|
false |
(applies to sun-appserv-deploy only, optional) If true, all JSP files found in an enterprise application (.ear) or web application (.war) are precompiled. This attribute is ignored for other component types. |
|
|
client stubs not saved |
(applies to sun-appserv-deploy only, optional) The directory where client stubs are saved. |
|
|
file name without extension |
(applies to sun-appserv-deploy only, optional) The context root for a web module (WAR file). This attribute is ignored if the component is not a WAR file. |
|
|
false |
(applies to sun-appserv-deploy only, optional) If true, syntax and semantics for all deployment descriptors is automatically verified for correctness. |
You can deploy multiple components using a single task. This example deploys each component to the same Application Server running on a remote server.
<sun-appserv-deploy passwordfile="${passwordfile}" host="greg.sun.com"
asinstalldir="/opt/s1as8" >
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"
contextroot="test"/>
<component file="${assemble}/simplebean.jar"/>
</sun-appserv-deploy>
You can also undeploy multiple components using a single task. This example demonstrates using the archive files (EAR and WAR, in this case) and the component name (for the EJB component).
<sun-appserv-undeploy passwordfile="${passwordfile}">
<component file="${assemble}/simpleapp.ear"/
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-undeploy>
You can enable or disable multiple components. This example demonstrates disabling multiple components using the archive files (EAR and WAR, in this case) and the component name (for the EJB component).
<sun-appserv-component action="disable" passwordfile="${passwordfile}">
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-component>
Selects component files that match specified parameters. When fileset is included as a subelement, the name and contextroot attributes of the containing element must use their default values for each file in the fileset. For more information, see http://ant.apache.org/manual/CoreTypes/fileset.html.