...
Overview
INLINE
The Geronimo-specific deployment plan for a Web application, which is usually packaged as a WAR file, is called "geronimo-web.xml".
...
Packaging
The geronimo-web.xml Geronimo-specific deployment plan can be packaged as follows:
- Embedded in a WAR file. In this case, a the geronimo-web.xml file must be placed in the /WEB-INF directory of the WAR, which is the same place where the web.xml file must be located.
- Maintained separately from the WAR file. : In this case, the path to the file must be provided to the appropriate Geronimo deployer (e.g., command-line or console) when the WAR file is deployed. Note that in this case, the filename can may be named something other than geronimo-web.xml but must adhere to the same schema. Also note that this will not work if the EJB JAR file is to be embedded in an enterprise application EAR file (see below).
- Embedded in an enterprise application EAR file: In one case, the highroot-level element <web-app> can be embedded in the of the geronimo-web-2.0.1.xsd schema can be embedded outside the WAR file in the EAR file's geronimo-application.xml file.
- Embedded in an enterprise application EAR file: In another case, the actual geronimo-web.xml file can be placed in the /META-INF directory of the EAR, which is the same location as the application.xml file.
Schema
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 briefly described documented here:
...
Top-level elements
The top-most element in the geronimo-web-2.0.1.xsd
is <web-app> element. The top-level elements of the <web-app> element are described below:
<sys:environment>
...
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.
...
...
...
- The <moduleId> element is used to provid the configuration name for the web application as deployed in the Geronimo server. It contains elements for the groupId, artifactId, version and module type. Module IDs are normally printed with slashes between the four components, such as GroupID/ArtifactID/Version/Type.
- The <dependencies> element is used to provide the configurations and third party libraries on which the web module is dependent upon. These configurations and libraries are made available to the web module via the Geronimo classloader hierarchy.
- The <hidden-classes> element can be used to specify a list of classes which will never be loaded from parent ClassLoaders of this module. For example, if Log4J was listed here, the module would never see Geronimo's copy of Log4J. If the module provided it's own Log4J JAR it would use that, otherwise it would not be able to load Log4J at all.
- The <non-overridable-classes> element can be used to specify a list of classes which will only be loaded from parent ClassLoaders of this module (never from the module's own ClassLoader). For example, this is used to prevent a web application from redefining "javax.servlet", so those classes will always be loaded from the server instead of from the web application's own ClassPath.
- The <inverse-classloading> element can be used to specify that standard classloader delegation is to be reversed for this module. * The <suppress-default-environment> element can be used to suppress inheritance of environment by module (i.e., any default environment built by a
Geronimo builder when deploying the plan will be suppressed).
An example geronimo-web.xml file is shown below using the <sys:environment> elements:
...
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.
Schema top-level elements
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:
...
<context-root>
The <context-root> uses the Geronimo default namespace for a geronimo-web.xml file that is described at http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1. 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.
<work-dir>
The <work-dir> uses the Geronimo default namespace for a geronimo-web.xml file that is described at http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1. 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.
<naming:web-container>
The <naming:web-container> uses the Geronimo naming namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-naming-1.2.xsd.html. It is used to specify a reference to a
web-container
specific GBean either via a pattern or via a link to a GBean. An example geronimo-web.xml file is shown below using the <naming:web-container> elements:
...
<sys:environment>
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:
- The <moduleId> element is used to provide the configuration name for the web application as deployed in the Geronimo server. It contains elements for the groupId, artifactId, version and module type. Module IDs are normally printed with slashes between the four components, such as GroupID/ArtifactID/Version/Type.
- The <dependencies> element is used to provide the configurations and third party libraries on which the web module is dependent upon. These configurations and libraries are made available to the web module via the Geronimo classloader hierarchy.
- The <hidden-classes> element can be used to provide some degree of control of the Geronimo classloader hierarchy, and mitigate clashes between classes loaded by the server and classes loaded by the web application. It is used to lists packages or classes that may be in a parent classloader, but must not be exposed to the web application. Since Geronimo is entirely open-source and utilizes many other open-source libraries it is possible that the server itself and the web application may have different requirements and/or priorities for the same open source project libraries. The <hidden-classes> element is typically used when the web application has requirements for a specific version of a library that is different than the version used by Geronimo itself. A simple example of this is when a web application uses, and most importantly includes, a version of the Log4J common logging library that is different than the version used by the Geronimo server itself. This might not provide the desired results. Thus, the <hidden-classes> element can be used to "hide" the Log4J classes loaded by all the parent classloaders of the web application module, including those loaded by and for the Geronimo server itself, and only the Log4J classes included with the web application library will get loaded.
- The <non-overridable-classes> element can also be used to provide some degree of control of the Geronimo classloader hierarchy, but in the exact opposite manner than provided by the <hidden-classes> element. This element can be used to specify a list of classes or packages which will only be loaded from the parent classloader of the web application module to ensure that the Geronimo server's version of a library is used instead of the version included with the web application.
- The <inverse-classloading> element can be used to specify that standard classloader delegation is to be reversed for this module. The Geronimo classloader delegation follows the Java EE 5 specifications, and the normal behavior is to load classes from a parent classloader (if available) before checking the current classloader. When the <inverse-classloading> element is used, this behavior is reversed and the current classloader will always be checked before looking in the parent classloader(s). This element is similar to the <hidden-classes> element since the desired behavior is to give the libraries packaged with the web application (i.e., in WEB-INF/lib) precedence over anything used by the Geronimo server itself.
- The <suppress-default-environment> element can be used to suppress inheritance of environment by module (i.e., any default environment built by a Geronimo builder when deploying the plan will be suppressed). If the <suppress-default-environment> element is specified then any default environment build by a builder when deploying the plan will be suppressed. An example of where this is useful is when deploying a connector on an app client in a separate (standalone) module (not as part of a client plan). The connector builder defaultEnvironment includes some server modules that won't work on an app client, so you need to suppress the default environment and supply a complete environment including all parents for a non-app-client module you want to run on an app client. This element should not be used for web applications however.
An example geronimo-web.xml file is shown below using the <sys:environment> element:
...
<context-root>
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.
<work-dir>
The <work-dir> XML element uses the Geronimo default namespace for the geronimo-web.xml file, and is documented here:
<container-config>
...
...
...
This element is used for the configuration of elements specific to the underlying Geronimo web container (i.e., Jetty or Tomcat). An example geronimo-web.xml file is shown below using the <container-config> elements for the Tomcat web container:
...
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
<sys:environment>
<sys:moduleId>
<sys:groupId>default</sys:groupId>
<sys:artifactId>geronimo-web-6</sys:artifactId>
<sys:version>1.0</sys:version>
<sys:type>car</sys:type>
</sys:moduleId>
<sys:dependencies>
<sys:dependency>
<sys:groupId>org.apache.geronimo.configs</sys:groupId>
<sys:artifactId>tomcat6</sys:artifactId>
<sys:version>2.2-SNAPSHOT</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
<sys:dependency>
<sys:groupId>default</sys:groupId>
<sys:artifactId>geronimo-web-5</sys:artifactId>
<sys:version>1.0</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
</sys:dependencies>
<sys:hidden-classes/>
<sys:non-overridable-classes/>
<sys:inverse-classloading/>
<sys:suppress-default-environment/>
</sys:environment>
<context-root>contextroot</web:context-root>
<work-dir>workdir</web:work-dir>
<naming:web-container>
<naming:pattern>
<naming:groupId>gbeanlocator-pattern-groupid</naming:groupId>
<naming:artifactId>gbeanlocator-pattern-artifactid</naming:artifactId>
<naming:version>gbeanlocator-pattern-version</naming:version>
<naming:module>gbeanlocator-pattern-module</naming:module>
<naming:name>gbeanlocator-pattern-name</naming:name>
</naming:pattern>
<naming:gbean-link>gbeanlocator-gbeanlink</naming:gbean-link>
</naming:web-container>
<container-config>
<tomcat xmlns="http://geronimo.apache.org/xml/ns/web/tomcat/config-1.0">
<host>testhost.com</host>
<valve-chain>FirstValve</valve-chain>
<tomcat-realm>TomcatRealm</tomcat-realm>
</tomcat>
</container-config>
</web-app>
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.
<naming:web-container>
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:
...
<container-config>
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:
- http://geronimo.apache.org/schemas-2.1/docs/geronimo-web-2.0.1.xsd.html
- http://geronimo.apache.org/schemas-2.1/docs/geronimo-tomcat-2.0.1.xsd.html
- http://geronimo.apache.org/schemas-2.1/docs/geronimo-jetty-2.0.2.xsd.html
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:
...
<sys:gbean>
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.
<ee:persistence>
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.
Security
Additional information and details for configuring security for Geronimo can be found here:
<security-realm-name>
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.
<sec:security>
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:
...
JNDI Environment References
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.
<naming:abstract-naming-entry>
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:
- <gbean-ref>
The <gbean-ref> element is used to map GBean references to GBeans configured outside the current module - <persistenceunit-ref>
The <persistenceunit-ref> element is used to map persistence unit references to persistence units configured outside the current module - <persistencecontext-ref>
The <persistencecontext-ref> element is used to map persistence context references to persistence contexts configured outside the current module
An example geronimo-web.xml file is shown below using the <abstract-naming-entry> element to reference a persistence unit:
...
<naming:ejb-ref>
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.
<naming:ejb-local-ref>
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.
<naming:service-ref>
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.
<naming:resource-ref>
The <naming:resource-ref> element is used to map resource references to resources like JDBC resources, JMS resources, etc. configured outside the current application.
<naming:resource-env-ref>
The <naming:resource-env-ref> element is used to map resource references to administrative objects deployed as a part of connectors.
<naming:message-destination>
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.
<naming:abstract-naming-entry>
The <naming:abstract-naming-entry> uses the Geronimo naming namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-naming-1.2.xsd.html. It is an abstract element used as a generic element for multiple reference types.
<naming:ejb-ref>
The <naming:ejb-ref> uses the Geronimo naming namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-naming-1.2.xsd.html. It 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 current application.
<naming:ejb-local-ref>
The <naming:ejb-local-ref> uses the Geronimo naming namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-naming-1.2.xsd.html. It 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 current application.
<naming:service-ref>
The <naming:service-ref> uses the Geronimo naming namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-naming-1.2.xsd.html. It 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.
<naming:resource-ref>
The <naming:resource-ref> uses the Geronimo naming namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-naming-1.2.xsd.html. It is used to map resource references to resources's like JDBC resources, JMS resources, etc. configured outside the current application.
<naming:resource-env-ref>
The <naming:resource-env-ref> uses the Geronimo naming namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-naming-1.2.xsd.html. It is used to map resource references to administrative objects deployed as a part of connectors.
<naming:message-destination>
The <naming:message-destination> uses the Geronimo naming namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-naming-1.2.xsd.html. It is used to configure a JMS queue
or topic which acts like a destination for the messages delivered.
<security-realm-name>
The <security-realm-name> uses the Geronimo default namespace for a geronimo-web.xml file that is described at http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1. It is used to specify the name of the security realm that will be used for user authentication.
<app:security>
The <app:security> uses the Geronimo applicaiton namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-application-2.0.xsd.html. It is used to maps roles specified in the WAR file to roles or principals in the security realm that will be used when deploying the module.
<sys:service>
The <sys:service> element uses the Geronimo deployment namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-module-1.2.xsd.html. It is an empty generic element to be extended by GBean and other module types.
<ee:persistence>
The <ee:persistence> element uses the persistence namespace described at http://java.sun.com/xml/ns/persistence/. Apache Geronimo uses OpenJPA for providing Java Persistence API to Java EE applications deployed in the server.
...