Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The Geronimo deployment plan for a Web application is an XML document. It is defined by the geronimo-web-1.1.xsd schema, which can be found in the <geronimo_home>/schema/ subdirectory of the main Geronimo installation directory. This deployment plan should be placed in WEB-INF folder and named as geronimo-web.xml and included in the Web application WAR.
The deployment plan should always use the Geronimo web namespace, and it typically requires elements from the Geronimo Naming namespace. Additionally, it has a required attribute to identify its configuration name, and an optional attribute to select a parent configuration. A typical Web application deployment plan will include the following attributes and should be placed in WEB-INF folder:

Code Block
xml
xml
borderStylesolid
titlegeronimo-web.xmlxml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
   xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
   xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
   xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
   xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1">
  ...
</web-app>

...

  • ModuleID and dependencies are defined in the <environment> block of an XML file. Any application or module can declare a moduleID for itself using moduleID element and can declare dependencies using the dependency element. The following snippet details the dependencies declared in the <enviroment> block.
Code Block
xml
xml
borderStylesolid
titleExcerpt from the sample application belowxml
<environment
 xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
  <moduleId> <groupId>geronimo</groupId>
  <artifactId>HelloWorld</artifactId>
  <version>1.1</version> <type>war</type> </moduleId>
</environment>

...

  1. Create a folder in called <app_home> in your working directory.
  2. Open up a new text file and save it as "HelloWorld.jsp" in side the app_home directory.
  3. Copy and past the following code for the "HelloWorld.jsp" in it.
    Code Block
    java
    java
    borderStylesolid
    titleHelloWorld.jspjava
      <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
          pageEncoding="ISO-8859-1"%>
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <title>HelloWorld!</title>
      </head>
      <body bgcolor="#707DB8">
         <h1>
            <font face="courier" color="white">
                     Hello world from GERONIMO v1.1!
             </font>
           </h1>
              <font face="courier" color="white"> ${datetime}</font>
      </html>
      
  4. Create a new folder called"WEB-INF" inside the <app_home>.
  5. Open up a new text file and save it as "geronimo-web.xml" and this is the Apache Geronimo v1.1 deployment plan for this sample module.
  6. Copy and paste the following xml code in that file and save it inside the <app_home\WEB-INF> directory.
Code Block
xml
xml
borderStylesolid
titlegeronimo-web.xmlxml
  <?xml version="1.0" encoding="UTF-8"?>
  <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1">
   <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
     <moduleId>
       <groupId>geronimo</groupId>
       <artifactId>HelloWorld</artifactId>
       <version>1.1</version>
       <type>war</type>
     </moduleId>
   </environment>
  <context-root>/hello</context-root>
   </web-app>
   
  1. Open up a another new text file save it in <app_home\WEB_INF> directory and name it as "web.xml"
  2. Copy and Paste the following xml code in it and save.
Code Block
xml
xml
borderStylesolid
titleweb.xmlxml
<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4"

    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <welcome-file-list>
         <welcome-file>HelloWorld.jsp</welcome-file>
    </welcome-file-list>

</web-app>

...

2.3.1 GBean reference example

Code Block
xml
xml
borderStylesolid
titleWEB-INF/geronimo-web.xmlxml
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1">
	<context-root>/gbean</context-root>
<!--gbean-ref: Holds all the settings for a single GBean reference
  ref-name: Each reference must have a ref-name, which is used to determine the JNDI name where the
  reference can be accessed by the web application. The specific JNDI location is java:comp/env/ plus the
  value specified here.
  ref-type: The ref-type specifies the interface that will be used for the JNDI entry. The GBean must
  implement this interface, and declare it in its GBeanInfo. 
  pattern: Identifies the specific GBean that this reference should point to. The pattern specified here 
  must uniquely identify a single GBean, though normally only the name is required to do so.-->

       <gbean-ref xmlns="http://geronimo.apache.org/xml/ns/naming-1.1">    
	
        <ref-name>gbeans/ServerInfo</ref-name>
        <ref-type>
          org.apache.geronimo.system.serverinfo.ServerInfo
        </ref-type>
        <pattern>
            <name>ServerInfo</name>
        </pattern>
    </gbean-ref>
  </web-app>

2.3.2 Accessing the GBean from the Web application

Code Block
java
java
borderStylesolid
titleGBeanInfo.jspjava
%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="org.apache.geronimo.system.serverinfo.ServerInfo"%>
<%@page import="javax.naming.InitialContext"%>
<%@page  import="javax.naming.Context"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GBean Refernce</title>
</head>
<body>
<tr>
<b>This Web Application refers a GBean</b>
</tr>
<tr>
<td>
<%
//Accessing the GBean Details from the WebApp
Context ctx =new InitialContext();
Object results =ctx.lookup("java:comp/env/gbeans/ServerInfo");
ServerInfo info  =(ServerInfo)results;
String str1 = info.getBaseDirectory();
String str2 = info.getVersion();
String str3 = info.getBuildDate();
String str4 = info.getBuildTime();
out.println("BaseDirectory :"+ str1+"\n");
out.println("Version:" +str2 + "\n");
out.println("Build Date:" + str3 +"\n");
out.println("Build Time:" + str4 + "\n");
%>
</td>
</tr>

</body>
</html>

...

This section will describe with the use of an example, how to refer an EJB from geronimo-web.xml. The the completed sample can be downloaded hereBasically this a program written to test whether how two ear are referring each other in geronimo.But It provides you the proper understanding in how to handle i deployment plan more clearly.

Code Block
xml
xml
borderStylesolid
titleWEB-INF/web.xmlxml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4"
    >

    <display-name>Geronimo EJBRef Itest War</display-name>

    <servlet>
        <display-name>Manifest ClassPath itest servlet</display-name>
        <servlet-name>servlet</servlet-name>
        <servlet-class>org.apache.geronimo.itest.TestServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>servlet</servlet-name>
        <url-pattern>/servlet</url-pattern>
    </servlet-mapping>

    <ejb-ref>
        <ejb-ref-name>TestSession</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>org.apache.geronimo.itest.TestSessionHome</home>
        <remote>org.apache.geronimo.itest.TestSession</remote>
    </ejb-ref>
    <ejb-ref>
        <ejb-ref-name>link-nonj2ee</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>org.apache.geronimo.itest.TestSessionHome</home>
        <remote>org.apache.geronimo.itest.TestSession</remote>
        <ejb-link>TestSession</ejb-link>
    </ejb-ref>
    <ejb-ref>
        <ejb-ref-name>link</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>org.apache.geronimo.itest.TestSessionHome</home>
        <remote>org.apache.geronimo.itest.TestSession</remote>
    </ejb-ref>
    <ejb-ref>
        <ejb-ref-name>noModuleId</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>org.apache.geronimo.itest.TestSessionHome</home>
        <remote>org.apache.geronimo.itest.TestSession</remote>
    </ejb-ref>
    <ejb-ref>
        <ejb-ref-name>moduleId</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>org.apache.geronimo.itest.TestSessionHome</home>
        <remote>org.apache.geronimo.itest.TestSession</remote>
    </ejb-ref>
    <ejb-ref>
        <ejb-ref-name>moduleId2</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>org.apache.geronimo.itest.TestSessionHome</home>
        <remote>org.apache.geronimo.itest.TestSession</remote>
    </ejb-ref>

</web-app>

Code Block
xml
xml
borderStylesolid
titleWEB-INF/geronimo-web.xmlxml
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web/jetty-1.1">
    <environment>
        <moduleId>
            <groupId>default</groupId>
            <artifactId>ejbref-war</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>car</type>
        </moduleId>
        <dependencies>
            <dependency>
                <groupId>default</groupId>
                <artifactId>ejbref-ejb-1.0-SNAPSHOT.jar</artifactId>
                <type>jar</type>
            </dependency>
        </dependencies>
    </environment>
    <ejb-ref>
        <ref-name>link</ref-name>
        <ejb-link>TestSession</ejb-link>
    </ejb-ref>
    <ejb-ref>
        <ref-name>noModuleId</ref-name>
        <pattern>
            <name>TestSession</name>
        </pattern>
    </ejb-ref>
    <ejb-ref>
        <ref-name>moduleId</ref-name>
        <pattern>
            <groupId>default</groupId>
            <artifactId>ejbref-ejb-1.0-SNAPSHOT.jar</artifactId>
            <name>TestSession</name>
        </pattern>
    </ejb-ref>
    <ejb-ref>
        <ref-name>moduleId2</ref-name>
        <pattern>
            <groupId>default</groupId>
            <artifactId>ejbref-ejb2-1.0-SNAPSHOT.jar</artifactId>
            <name>TestSession</name>
        </pattern>
    </ejb-ref>
</web-app>

2.4.2 Accessing the EJB from the Web application

Code Block
java
java
2title
borderStylesolidjava
public class TestServlet extends HttpServlet {

    public void init() {
        System.out.println("Test Servlet init");
        try {
            InitialContext ctx = new InitialContext();
            TestSessionHome home = (TestSessionHome)ctx.lookup("java:comp/env/TestSession");
            home.create();
            System.out.println("Test Servlet looked up java:comp/env/TestSession");
            home = (TestSessionHome)ctx.lookup("java:comp/env/link-nonj2ee");
            home.create();
            System.out.println("Test Servlet looked up java:comp/env/link-nonj2ee");
            home = (TestSessionHome)ctx.lookup("java:comp/env/link");
            home.create();
            System.out.println("Test Servlet looked up java:comp/env/link");
            home = (TestSessionHome)ctx.lookup("java:comp/env/noModuleId");
            home.create();
            System.out.println("Test Servlet looked up java:comp/env/noModuleId");
            home = (TestSessionHome)ctx.lookup("java:comp/env/moduleId");
            home.create();
            System.out.println("Test Servlet looked up java:comp/env/moduleId");
            home = (TestSessionHome)ctx.lookup("java:comp/env/moduleId2");
            home.create();
            System.out.println("Test Servlet looked up java:comp/env/moduleId2 from unrelated jar");
        } catch (NamingException e) {
            System.out.print("Exception:");
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

    protected void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws 
    ServletException, IOException {
        httpServletResponse.getWriter().print("TestServlet");
        httpServletResponse.flushBuffer();
    }


}

...

This section will refer the application in JMS and MDB sample application (1.2 Ok). In the sample, Order Processing Web application sends messages to the Order Queue. OrderSenderServlet will handle the relevant order request generation and the sending. web.xml of the archive has the relevant configurations for the both queue connection factory and the queue, which is essential to refer resources in a local enviroment.This section is described how it has implemented in the geronimo-web.xml in xml code base.As stated earlier, the following deployment plans are taken from the JMS and MDB sample application (1.2 Ok)

Code Block
xml
xml
borderStylesolid
titleweb.xmlxml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
 <servlet> 
  <display-name>OrderSenderServlet</display-name>
       <servlet-name>OrderSenderServlet</servlet-name> 
          <servlet-class>org.apache.geronimo.samples.order.web.OrderSenderServlet</servlet-class> 
 </servlet> 
  <servlet-mapping> <servlet-name>OrderSenderServlet</servlet-name> <url-pattern>/order</url-pattern>
  </servlet-mapping>
  <resource-ref> 
      <res-ref-name>jms/CommonConnectionFactory</res-ref-name> 
        <res-type>javax.jms.QueueConnectionFactory</res-type>
         <res-auth>Container</res-auth> 
          <res-sharing-scope>Shareable</res-sharing-scope>
  </resource-ref> 
          <message-destination-ref>
              <message-destination-ref-name>jms/OrderQueue</message-destination-ref-name> 
                  <message-destination-type>javax.jms.Queue</message-destination-type> 
                    <message-destination-usage>Produces</message-destination-usage> 
                      <message-destination-link>OrderQueue</message-destination-link> 
          </message-destination-ref> 
  <welcome-file-list>
          <welcome-file>/jsp/index.jsp</welcome-file> 
  </welcome-file-list> 
</web-app>

In the web.xml there are several XML elements to be set to access a JMS resource. In this case the jms/CommonConnectionFactory is the JMS resource band, it also sets values to the child element of it within the resource-ref segment <recoure-ref>..</resource-ref>
The message-destination element declares the Queue, and the message-destination-ref declares a reference to it. This works automatically in Geronimo if the message-destination-name specified above matches the adminobject/message-destination-name in the Geronimo deployment plan for the JMS destination (though the message destination should have been deployed already). In this case there's no need for any more configuration in the WAR – in particular, the only setting needed in the geronimo-web.xml deployment plan is a dependency on the JMS resource group including that destination.
For reference, here's a snippet from a JMS connector deployment plan that matches the WAR configuration, geronimo-web.xml will act as a mediator between defined JMS resources in the application server and the web.xml.

Code Block
xml
xml
borderStylesolid
titleCode snippet from JMS connector deployment planxml
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1" 
    xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1">
    <dep:environment 
     xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
        <dep:moduleId> 
            <dep:groupId>samples</dep:groupId>
               <dep:artifactId>OrderWeb</dep:artifactId>
                <dep:version>1.0</dep:version>
                  <dep:type>car</dep:type> </dep:moduleId>
     <dep:dependencies> 
            <dep:dependency> 
                <dep:groupId>geronimo</dep:groupId>
                 <dep:artifactId>activemq-broker</dep:artifactId> 
                   <dep:type>car</dep:type>
            </dep:dependency> 
            <dep:dependency> 
                <dep:groupId>samples</dep:groupId> 
                <dep:artifactId>jms-resources</dep:artifactId> 
                  <dep:version>1.0</dep:version> 
                    <dep:type>rar</dep:type> 
                   </dep:dependency>
              </dep:dependencies> 
       <dep:hidden-classes/>
       <dep:non-overridable-classes/> 
  </dep:environment> 
 <context-root>/Order</context-root> 
   <resource-ref> <ref-name>jms/CommonConnectionFactory</ref-name> 
   <resource-link>CommonConnectionFactory</resource-link> 
  </resource-ref>
 <resource-env-ref> 
   <ref-name>jms/OrderQueue</ref-name> 
  <admin-object-link>OrderQueue</admin-object-link>
 </resource-env-ref> </web-app>

Considering the geronimo-web.xml deployment plan, there are few settings that have to be done to refer this JMS resource. The JMS supporting resource of the Geronimo server is required to be avaliable in the deployment plan itself. Therefore, the dependencies are set as follows which makes the resource available to the application.Let's take look at the following code segment

Code Block
xml
xml
borderStylesolidxml
<dep:dependencies> 
  <dep:dependency> 
             <dep:groupId>geronimo</dep:groupId> 
                   <dep:artifactId>activemq-broker</dep:artifactId> 
                   <dep:type>car</dep:type> 
 </dep:dependency> 
......
</dep:dependencies> 

As shown in the above code excerpt of the deployment plan, this dependency is physically located in <geronimo-home>/repositories/geronimo/activemq-broker/1.1.1/activemq-broker-1.1.1.car
Furthermore, the following piece of code is presented in the way that resource references are set.
Jms/CommonConnectionFactory is the JMS resource Type we have used to create the JMS Queue. It has been defined in the <resource-ref> and the <resource -env-ref> segments, and are carrying the name of the resource created in the Geronimo server. Therefore, OrderQueue is the Queue created and deployed in the server.

Code Block
xml
xml
borderStylesolidxml
<resource-ref> 
       <ref-name>jms/CommonConnectionFactory</ref-name> 
       <resource-link>CommonConnectionFactory</resource-link>
 </resource-ref>

 <resource-env-ref> 
      <ref-name>jms/OrderQueue</ref-name> 
      <admin-object-link>OrderQueue</admin-object-link> 
</resource-env-ref> 

...

This section will describe how to refer Database pools in Web applications. This is describing using Simple database access sample application (1.2 Ok) and it's database pool deployment plan. Application defines a datasource with the help of geronimo-web.xml and web.xml files. geronimo-web.xml adds a link between the database pool already deployed in the server. It refers to the database pool via it's artifactID. According to the given geronimo-web.xml deployment plan, the artifactID is given as InventoryApp, which is the name of the database pool connection which has created for this sample application. Furthermore, the dependencies are set to console.dbpool as the groupID and InventoryPool as the artifactID of it. InventoryPool is the name of the Database connection plan. All of the work mentioned earlier is not enough to give a reference to a Database connection and it should be followed by the resource reference tags in the geronimo-web.xml as well as in web.xml.

Code Block
xml
xml
borderStylesolid
titlegeronimo-web.xmlxml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
        xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1">
        
        <environment>
                <moduleId>
                        <artifactId>InventoryApp</artifactId>
                </moduleId>
                <dependencies>
            <dependency>
                <groupId>console.dbpool</groupId>
                <artifactId>InventoryPool</artifactId>
            </dependency>
        </dependencies>         
        </environment>
                
        <context-root>/inventory</context-root>
        
        <!-- define a reference name to the db pool-->
        <resource-ref>
        <ref-name>jdbc/InventoryDS</ref-name>
        <resource-link>InventoryPool</resource-link>
    </resource-ref>    
</web-app>

The following is the web.xml of the Inventory application. It uses the same name as in geronimo-web.xml, which is used to create the datasource. In the web.xml the Data connection pool has been exposed as a datasource in a <resource-ref> and had set the value to jdbc/InventoryDS.

Code Block
xml
xml
borderStylesolid
titleweb.xmlxml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4"> 
         
        <welcome-file-list>
                <welcome-file>welcome.jsp</welcome-file>
        </welcome-file-list>  
        
        <servlet>
            <display-name>AddItemServlet</display-name>
            <servlet-name>AddItemServlet</servlet-name>
            <servlet-class>org.apache.geronimo.samples.inventory.web.AddItemServlet</servlet-class>
        </servlet>
        <servlet>
            <display-name>IssueingServlet</display-name>
            <servlet-name>IssueingServlet</servlet-name>
            <servlet-class>org.apache.geronimo.samples.inventory.web.IssueingServlet</servlet-class>
        </servlet>
        <servlet>
            <display-name>RecievingServlet</display-name>
            <servlet-name>RecievingServlet</servlet-name>
            <servlet-class>org.apache.geronimo.samples.inventory.web.RecievingServlet</servlet-class>
        </servlet>
        
        <servlet-mapping>
            <servlet-name>AddItemServlet</servlet-name>
            <url-pattern>/add_item</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>IssueingServlet</servlet-name>
            <url-pattern>/issue</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>RecievingServlet</servlet-name>
            <url-pattern>/recv</url-pattern>
        </servlet-mapping>
    
        <!-- reference name exposed as a datasource -->
        <resource-ref>
            <res-ref-name>jdbc/InventoryDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>
    
</web-app>

The application server going to access InventoryDB through a connection pool. In the sample the steps to create the connection pool(Simple database access sample application (1.2 Ok)).When it comes to this level, we have already discussed deployment plans and now the Database connection pool plan is going to be discussed further. This plan can be created using the Geronimo web console.

Code Block
xml
xml
borderStylesolid
titleInventoryPool.xmlxml
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.1">
    <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
        <dep:moduleId>
            <dep:groupId>console.dbpool</dep:groupId>
            <dep:artifactId>InventoryPool</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>rar</dep:type>
        </dep:moduleId>
        <dep:dependencies>
            <dep:dependency>
                <dep:groupId>geronimo</dep:groupId>
                <dep:artifactId>system-database</dep:artifactId>
                <dep:type>car</dep:type>
            </dep:dependency>
        </dep:dependencies>
    </dep:environment>
    <resourceadapter>
        <outbound-resourceadapter>
            <connection-definition>
                <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
                <connectiondefinition-instance>
                    <name>InventoryPool</name>
                    <config-property-setting 
name="Driver">org.apache.derby.jdbc.EmbeddedDriver</config-property-setting>
                    <config-property-setting name="UserName">app</config-property-setting>
                    <config-property-setting name="ConnectionURL">jdbc:derby:InventoryDB</config-property-setting>
                    <connectionmanager>
                        <local-transaction/>
                        <single-pool>
                            <max-size>10</max-size>
                            <min-size>0</min-size>
                            <match-one/>
                        </single-pool>
                    </connectionmanager>
                </connectiondefinition-instance>
            </connection-definition>
        </outbound-resourceadapter>
    </resourceadapter>
</connector>

Let's consider the following code segment which starts with <enviornment> segment.

Code Block
xml
xml
borderStylesolidxml
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.1">
    <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
        <dep:moduleId>
            <dep:groupId>console.dbpool</dep:groupId>
            <dep:artifactId>InventoryPool</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>rar</dep:type>
        </dep:moduleId>
        <dep:dependencies>
            <dep:dependency>
                <dep:groupId>geronimo</dep:groupId>
                <dep:artifactId>system-database</dep:artifactId>
                <dep:type>car</dep:type>
            </dep:dependency>
        </dep:dependencies>
    </dep:environment>

...

There is a Web application security sample (1.2 Ok) already under sample applications.Considering the implementation of the security of geronimo-web.xml, this describes how to add a security setting in a web app.

Code Block
xml
xml
borderStylesolid
titleWEB-INF/web.xmlxml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4"> 
         
        <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        
        <security-constraint>
                <web-resource-collection>
                        <web-resource-name>employee</web-resource-name>
                        <url-pattern>/employee/*</url-pattern>                  
                </web-resource-collection>
                <auth-constraint>
                        <role-name>employee</role-name>                  
                </auth-constraint>
        </security-constraint>
        
        <security-constraint>
                <web-resource-collection>
                        <web-resource-name>manager</web-resource-name>
                        <url-pattern>/manager/*</url-pattern>                   
                </web-resource-collection>
                <auth-constraint>
                        <role-name>manager</role-name>
                </auth-constraint>
        </security-constraint>
        
        <login-config>
                <auth-method>FORM</auth-method>
                <realm-name>TimeReportRealm</realm-name>
                <form-login-config>
                        <form-login-page>/login/login.jsp</form-login-page>
                        <form-error-page>/login/login_error.jsp</form-error-page>
                </form-login-config>
        </login-config>
        
        <security-role>
                <role-name>employee</role-name>         
        </security-role>
        <security-role>
                <role-name>manager</role-name>          
    </security-role>
        
    <servlet>
            <display-name>AddTimeRecordServlet</display-name>
            <servlet-name>AddTimeRecordServlet</servlet-name>
            <servlet-class>org.timereport.web.employee.AddTimeRecordServlet</servlet-class>
        </servlet>
        <servlet>
            <display-name>AddEmployeeServlet</display-name>
            <servlet-name>AddEmployeeServlet</servlet-name>
            <servlet-class>org.timereport.web.manager.AddEmployeeServlet</servlet-class>
        </servlet>
        
        <servlet-mapping>
            <servlet-name>AddTimeRecordServlet</servlet-name>
            <url-pattern>/employee/add_timerecord</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
            <servlet-name>AddEmployeeServlet</servlet-name>
            <url-pattern>/manager/add_employee</url-pattern>
    </servlet-mapping>
        
</web-app>
Code Block
xml
xml
borderStylesolid
titlegeronimo-web.xmlxml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
        xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1">
        
        <environment>
                <moduleId>
                        <artifactId>TimeReportApp</artifactId>
                </moduleId>             
        </environment>
                
        <context-root>/timereport</context-root>
        
        <security-realm-name>TimeReportRealm</security-realm-name>
        
        <security>
                <default-principal realm-name="TimeReportRealm">
                        <principal name="anonymous"
                                   class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"
                                   />
                </default-principal>
                <role-mappings>                 
                        <role role-name="employee">
                                <realm realm-name="TimeReportRealm">
                                        <principal name="EmployeeGroup"
                                         class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"
                                        />
                                </realm>
                                <realm realm-name="TimeReportRealm">
                                        <principal name="ManagerGroup"
                                         class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"
                                        />                                      
                                </realm>
                        </role>
                        <role role-name="manager">
                                <realm realm-name="TimeReportRealm">
                                        <principal name="ManagerGroup"
                                           class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"
                                        />                                      
                                </realm>                                                                
                        </role>
                </role-mappings>
    </security>
    
</web-app>

...