Overview
The Geronimo deployment plan for a Web application, which is usually packaged as a WAR file is called "geronimo-web.xml
". The geronimo-web.xml
deployment plan is used to in conjunction with the web.xml
JAVA EE deplopyment plan to deploy web applications consisting of Java Servlet Pages (JSP) and servlets to the Geronimo application server, and optionally can be used to configure the Geronimo web server (i.e., Tomcat or Jetty) where the Web application is going to be deployed. The geronimo-web.xml
deployment plan is an optional file, but is typically used when deploying a WAR file. It is used to specify the application security roles, ejb names, database resources, JMS resources, etc. declared in web.xml
to corresponding entities deployed in the server. In addition to that, if there are any web container specific configurations, such as Tomcat or Jetty specific, depending on the application needs, all these settings are configured as well here. If the web application depends on any third party libraries or other services running in the server, all these dependencies are declared in the plan. Some web applications require class loading requirements different from the default class loading behavior. The geronimo-web.xml
allows application deployer to configure this as well. There are many more configurations that could be done through geronimo-web.xml
depending on the needs of web application.
Packaging
The geronimo-web.xml
deployment plan can be packaged as follows:
- Embedded in a WAR file. In this case, a
geronimo-web.xml
file must be placed in the /WEB-INF directory of the WAR, which is the same place where theweb.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). Note that in this case, the filename can be named something other than
geronimo-web.xml
but must adhere to the same schema. - Embedded in an enterprise application EAR file: In one case, the high-level element <web-app> can be embedded 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 theapplication.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 here:
http://geronimo.apache.org/schemas-2.1/docs/geronimo-web-2.0.1.xsd.html
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>
The <sys:environment> elements use the Geronimo deployment namespace described at http://geronimo.apache.org/schemas-2.1/docs/geronimo-module-1.2.xsd.html. The <sys:environment> contains the following elements:
- 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:
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1" 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:dependency> <sys:groupId>default</sys:groupId> <sys:artifactId>geronimo-web-4</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> </web-app>
<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:
<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:dependency> <sys:groupId>default</sys:groupId> <sys:artifactId>geronimo-web-4</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> </web-app>
<container-config>
The <container-config> 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 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:dependency> <sys:groupId>default</sys:groupId> <sys:artifactId>geronimo-web-4</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>
<naming:abstract-naming-entry>
<ejb-ref>
The <context-root> uses the default namespaced described at
'The element ejb-ref 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.'
<ejb-local-ref>
The <context-root> uses the default namespaced described at
'The element ejb-local-ref 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.'
<service-ref>
The <context-root> uses the default namespaced described at
'The element 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.'
<resource-ref>
The <context-root> uses the default namespaced described at
'The element resource-ref is used to map resource references to resources\'s like JDBC resources, JMS resources, etc. configured outside the current application.'
<resource-env-ref>
The <context-root> uses the default namespaced described at
'The element resource-env-ref is used to map resource references to administrative objects deployed as a part of connectors.'
<naming:message-destination>
The <context-root> uses the default namespaced described at
References a message-destination (such as JMS queues), which is used within the deployed WAR file.
<security-realm-name>
The <context-root> uses the default namespaced described at
Specifies the name of the security realm that will be used for user authentication.
<app:security>
The <context-root> uses the default namespaced described at
Configures the security role mappings that will be used when deploying the module. Maps roles specified in the WAR file to roles or principals in the security realm
<sys:service>
The <context-root> uses the default namespaced described at
'Reference to abstract service element defined in imported \"geronimo-module-1.2.xsd\"'
<ee:persistence>
The <context-root> uses the default namespaced described at
default namespace is http://java.sun.com/xml/ns/javaee
. The XML elements that do not have a namespace prefix belong to the default namespace.