Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For example, the following Geronimo-web.xml is the deployment plan of a web application that connects to a datasource deployed on DB2 and retrieves data.web.xml and geronimo-web.xml are the deployment plans of a web application that connects to a datasource deployed on DB2 and retrieves data.

Sample web.xml

Code Block

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

  <resource-ref>
    <res-ref-name>jdbc/DataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
  </resource-ref>
 
  <welcome-file-list>  
    <welcome-file>jsp/EMPdemo.jsp</welcome-file>  
  </welcome-file-list>  
</web-app>

Sample geronimo-web.xml 

Code Block
<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:sec="http://geronimo.apache.org/xml/ns/security-2.0"
          xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">

     <sys:environment>
         <sys:moduleId>
             <sys:groupId>samples</sys:groupId>
             <sys:artifactId>EmployeeDemo</sys:artifactId>
             <sys:version>2.1</sys:version>
             <sys:type>war</sys:type>
         </sys:moduleId>
         <sys:dependencies>
             <sys:dependency>
                 <sys:groupId> samples</sys:groupId>
                 <sys:artifactId>EmployeeDatasource</sys:artifactId>
                 <sys:version>2.1</sys:version>
                 <sys:type>rar</sys:type>
             </sys:dependency>
         </sys:dependencies>
     </sys:environment>

     <context-root>/EmployeeDemo</context-root>

     <naming:resource-ref>
         <naming:ref-name>jdbc/DataSource</naming:ref-name>
         <naming:resource-link>jdbc/EmployeeDatasource</naming:resource-link>
     </naming:resource-ref>


 </web-app>

 Please Please observe the different namespace prefixes and corresponding namespaces used to configure dependencies and resource mapping. Also observe how the Datasource name 'jdbc/DataSource' in web.xml is mapped to 'jdbc/EmployeeDatasource' in geronimo-web.xml.

The deployment plan starts with <sys:moduleId> to provide a unique module id configuration for the web application. In dependencies section, using <sys:dependency>, a dependency on "samples/EmployeeDatasource/2.1/rar" is configured. This is the module id of Datasource that connects to DB2. The web context root is configured by <context-root>. Since there is no namespace prefix for this tag, it is going to be the default namespace http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1. The datasource name "jdbc/Datasource" is mapped to "SystemDatasource" using <naming:resource-ref>.

...