You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 24 Next »

Overview

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 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 requirements of web application.

Packaging

The geronimo-web.xml Geronimo-specific deployment plan can be packaged as follows:

  1. Embedded in a WAR file. In this case, 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.

  2. 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 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).

  3. Embedded in an enterprise application EAR file: In one case, the high-level element <web-app> can be embedded outside the WAR file in the EAR file's geronimo-application.xml file.

  4. 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 documented here:

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 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:

<sys:environment> example
<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: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/schemas-2.1/docs/geronimo-web-2.0.1.xsd.html. 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/schemas-2.1/docs/geronimo-web-2.0.1.xsd.html. 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:

<naming:web-container> example
<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>

</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/schemas-2.1/docs/geronimo-web-2.0.1.xsd.html. 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:

<container-config> example
<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>

<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/schemas-2.1/docs/geronimo-web-2.0.1.xsd.html. 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.

Samples

  • No labels