Home > Documentation > Creating deployment plans > Understanding deployment plans > geronimo-web.xml |
The Geronimo-specific deployment plan for a Web application, which is usually packaged as a WAR file, is called "geronimo-web.xml".
The geronimo-web.xml Geronimo-specific deployment plan can be packaged as follows:
The geronimo-web.xml deployment plan is defined by the geronimo-web-2.0.1.xsd schema located in the <geronimo_home>/schema/ subdirectory of the main Geronimo installation directory. The geronimo-web-2.0.1.xsd schema is documented here:
This schema is not container-specific, meaning that it can be used to deploy a web application to either of the Tomcat or Jetty web containers supported by Geronimo. If it is necessary to deploy to a specific container, one of the two following container-specific schemas can be used instead. These allow container-specific configuration elements that are only understood by either the Tomcat or Jetty web container.
Finally, while the generic schema has no container-specific elements, it does facilitate the inclusion of container-specific elements by using the <container-config> element. This element is described in more detail below.
The root XML element in the geronimo-web-2.0.1.xsd schema is the <web-app> element. The top-level XML elements of the <web-app> root element are described in the sections below. The deployment plan should always use the Web application namespace, and it typically requires elements from Geronimo System, Geronimo Naming, Geronimo Security, Geronimo Application, and Geronimo Persistence namespaces. Additionally, it has a required attribute to identify its configuration name, and an optional attribute to select a parent configuration. A typical deployment for geronimo-web.xml can be presented as follows:
The <sys:environment> XML element uses the Geronimo System namespace, which is used to specify the common elements for common libraries and module-scoped services, and is documented here:
The <sys:environment> element contains the following elements:
An example geronimo-web.xml file is shown below using the <sys:environment> element:
The <context-root> XML element uses the Geronimo default namespace for the geronimo-web.xml file, and is documented here:
This element can be used to provide the web context path of the deployed web application, which appears in the URL used to address the application on a Geronimo server. As an example, if the context root is specified as <context-root>web-app-test</context-root> then the URL to the application would look like http://host:8080/web-app-test/. If the context root is specified as <context-root>/</context-root> that would become the default web application for the server. The <context-root> element is optional, but if it is not specified the context root of the web application will default to the WAR name (without the extension). If the web application is packaged in an EAR, then the context root can be specified
in the EAR's application.xml deployment descriptor.
The <work-dir> XML element uses the Geronimo default namespace for the geronimo-web.xml file, and is documented here:
This element can be used to provide the work directory that will be used by this web application. For Jetty this will be relative to jetty home which is var/jetty by default, and for Tomcat this will be relative to catalina.home.
The <naming:web-container> XML element uses the Geronimo Naming namespace, which is used to identify the common elements for resolving EJB references, resource references, and Web services references, and is documented here:
This element is used to specify a reference to a web-container specific GBean either via a pattern to the moduleId of the configuration, or via a link to a GBean. As an example, consider the case where it is required to run a web application in a Tomcat container using a dedicated port such that no other web application is allowed to use that port. To accomplish this a separate GBean would have to be defined for the "Container", "Engine", "Host", and "Connector", and a <naming:web-container> element would have to be used to reference this new Tomcat container. An example geronimo-web.xml file is shown below:
As previously mentioned, there are actually three schemas that can be used for the geronimo-web.xml file. The first is container-independent and can be used to deploy a web application to either of the web containers supported by Geronimo. The second two are container-dependent that contain elements specific to either the Tomcat or Jetty web container:
Which to use is left to the discretion of the user. If a web application is meant to be deployed to both Tomcat and Jetty, then the generic schema is typically used, and if a web application is meant to be deployed to only Tomcat or Jetty, then one of the container-specific schemas is typically used. However, another option is available since the generic schema allows the inclusion of the container-specific elements found in the container-specific schemas by using the <container-config> element. This allows the user to use the generic schema even when the web application requires container-specific configuration for Tomcat or Jetty (or both). An example geronimo-web.xml file is shown below using the <container-config> element to configure the Tomcat web container. Note that the <host>, <valve-chain>, and <tomcat-realm> elements are understood only by the Tomcat container, not Jetty:
The <sys:gbean> XML element uses the Geronimo System namespace, and is documented here:
The <sys:gbean> element is used to define GBean(s) that are configured and deployed with the web application module. These additional Geronimo services will be deployed when the application is deployed (and stopped when the application is stopped). Normally, the implementation classes for these services are included at the server level and referenced using a dependency element.
The <ee:persistence> XML element uses the Java EE Persistence namespace, and is documented here:
Apache Geronimo uses OpenJPA for providing Java Persistence API to Java EE applications deployed in the server. The persistence deployment descriptor information is typically provided using a persistence.xml file. The <ee:persistence> top-level element can be used include the persistence deployment descriptor in the geronimo-web.xml file. More information and details about the JPA deployment descriptor can be found here: Creating deployment plans for Java Persistence API.
Additional information and details for configuring security for Geronimo can be found here:
The <security-realm-name> XML element uses the Geronimo default namespace for the geronimo-web.xml file, and is documented here:
The <security-realm-name> element is used to specify the name of the security realm that will be used for user authentication for the web application. It is used in conjunction with the <security-constraint> element in the corresponding web.xml deployment plan for this web application. This element will not cause the creation of a new security realm in Geronimo, it references a security realm that has already been created and configured. See Administering Security for details on how this is typically accomplished from the Geronimo Admin Console.
The <sec:security> XML element uses the Geronimo Security namespace, and is documented here:
The <sec:security> element groups the security role mapping settings for the web application. This is an optional element, but if it is present all the web modules must make the appropriate access checks as outlined in the JACC specification. This element includes the <role-mapping> section that references the role(s) defined in the <security-role> element in the web.xml file. An example web.xml and corresponding geronimo-web.xml file is shown below with the "admin" role name defined in the web.xml is referenced in the geronimo-web.xml:
All the JNDI reference elements in this section use the Geronimo Naming namespace, which is used to identify the common elements for resolving EJB references, resource references, and Web services references, and is documented here:
Additionally, more information and details about JNDI references can be found here: Global JNDI.
The <abstract-naming-entry> element is not technically a JNDI reference element. It is included in this section because it is an abstract element used for containing these JNDI reference types:
An example geronimo-web.xml file is shown below using the <abstract-naming-entry> element to reference a persistence unit:
The <naming:ejb-ref> element is used to map EJB references to EJB's in other applications using remote home and remote interface. The application which contains the EJB being referenced should either be in same EAR or should be included in dependency list of this application. Also note as the EJB's referenced are in a different JVM all the client interfaces should also be included in the current application.
The <naming:ejb-local-ref> element is used to map EJB references to EJB's in other applications using local home and local interface. The application which contains the EJB being referenced should either be in same EAR or should be included in dependency list of this application. Also note as the EJB's referenced are in a different JVM all the client interfaces should also be included in the current application.
The <naming:service-ref> is used to map service references to service's in other applications. The application which contains the EJB being referenced should either be in same EAR or should be included in dependency list of this application.
The <naming:resource-ref> element is used to map resource references to resources like JDBC resources, JMS resources, etc. configured outside the current application.
The <naming:resource-env-ref> element is used to map resource references to administrative objects deployed as a part of connectors.
The <naming:message-destination> element is used to map resource references to a message-destination which is used within the deployed web application. These are typically a JMS queue or topic which acts like a destination for the messages delivered. Like all the JNDI references in this section, this element will not cause the creation of a message-destination, references an existing message-destination used within the deployed web application.
Bookmark this on Delicious Digg this | Privacy Policy - Copyright © 2003-2011, The Apache Software Foundation, Licensed under ASL 2.0. |