Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Every module that you install in Geronimo, whether it is a service, application, resource, etc., can be configured via a deployment plan. These deployment plans are XML files based on XML Schemas containing the configuration details for a specific application module or component. The Java EE 5 specification defines standard deployment descriptors such as web.xml, application.xml and so on. In some cases, the deployment descriptor is all that is required to install a module into a Geronimo server. However, in many cases, server-specific configuration is required when modules are installed. This server-specific configuration is accomplished by using Geronimo deployment plans.

...

This document is organized in the following sections:

...

XML Schemas

Java EE Deployment Plans

...

...

The default namespace of the above XML document is http://geronimo.apache.org/xml/ns/j2ee/connector-1.2. The XML elements that do not have a namespace prefix belong to the default namespace.

...

...

The default namespace of the deployment plan is http://geronimo.apache.org/xml/ns/j2ee/connector-1.2. The xml elements that do not have a namespace prefix belong to default namespace.

...

...

The default namespace of the above XML document is http://geronimo.apache.org/xml/ns/deployment-1.2. The XML elements that do not have a namespace prefix belong to the default namespace.

...

...

The default namespace of the above XML document is http://java.sun.com/xml/ns/javaee. The XML elements that do not have a namespace prefix belong to the default namespace.

With Servlet 2.5 specification, many of the declarations done through web.xml can also be done through corresponding annotations in the servlets and JSPs. When both annotations and web.xml are provided, the declarations in web.xml takes precedence over annotations.

...

The default namespace of the above XML document is http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1. The XML elements that do not have a namespace prefix belong to the default namespace.

...

In the EMPdemo.jsp, the following java code snippet is used to obtain a connection from the datasource.

...

...

The above descriptor and the plan files are the simple illustrations that explain how web modules are developed and assembled for Apache Geronimo. Similarly, many other configurations can be performed in the geronimo-web.xml.

...

For example, the below XML content is the deployment descriptor (ejb-jar.xml) of a stateless session bean that connects to a back end DB2 database.

...

...

The default namespace of the above XML document is http://java.sun.com/xml/ns/javaee. The XML elements that do not have a namespace prefix belong to the default namespace.

In EJB3.0, most of the deployment descriptor declarations can be done through the corresponding annotations in the bean class. However, if a deployment descriptor is supplied (ejb-jar.xml), the declarations in the deployment descriptor will override the annotations.

The ejb module connects to back end datasource using its JNDI name jdbc/DataSource as declared in the ejb-jar.xml. It also declares that the ejb is a stateless session bean and provides an interceptor class for the bean. The interceptor class will have callback methods which container calls when the corresponding events occur in the bean's life cycle.

...

The default namespace of the above XML document is http://openejb.apache.org/xml/ns/openejb-jar-2.2. The XML elements that do not have a namespace prefix belong to the default namespace.

...

In the ejb bean class, the following java code is used to obtain a connection from the datasource.

...

The above descriptor and plan are the simple illustrations that explain how ejb modules are developed and assembled for Apache Geronimo. Similarly, many other configurations can be performed in the openejb-jar.xml. The schema for the plan is openejb-jar-2.1.xsd

...

An enterprise application archive (EAR) can consist of many sub modules. The sub modules can be web modules (WAR), ejb modules (JAR), resource adapter modules (RAR) or application client modules (jar). When an EAR consist of many sub modules, the deployment plans for all the sub modules can be provided in a single file named geronimo-application.xml. This single file contains the deployment details of each of the sub modules of the EAR. Alternatively, each of the sub modules can package its corresponding deployment plan file within itself. However, the preferable way is to provide a single deployment plan through geronimo-application.xml for all the sub modules. This mechanism provides flexibility of allowing us to modify the deployment configuration for all modules through a single file. In this section, we explore EAR deployment plan and understand what it contains.

...

...

There are 3 places a deployment plan (partial) can be associated with an ear, and they are used in this order:

1. external plan to be specified at deployment time
2. ear level geronimo-application.xml
3. module level geronimo|openejb-*.xml

So, anything in an external plan takes precedence over bits in (2) or (3) configuring the same module. Anything in (2) takes precedence over a module level plan. If a module level plan is missing from (1) its looked for in (2),then (3); if missing from (1) and (2), then its looked for in the module (3).

There is no attempt to merge plans from these different locations: e.g. if there's something in (1) for a module, any other plans are ignored.

...

An enterprise application archive (EAR) should provide its deployment descriptor in the application.xml file. The application.xml lists all the sub modules in the EAR file along with the descriptions. In addition to the standard deployment descriptor, the EAR should also provide Geronimo specific deployment plan in geronimo-application.xml. Along with the description of each of the sub modules of the EAR file, this file also provides mappings for JEE resources that each of the sub modules refers in their deployment descriptor. The geronimo-application.xml is divided into several sections where in each section, the deployment plan for a sub module is provided. geronimo-application.xml is the highest level plan that provides deployment plan for all sub modules; hence it can contain XML elements from every other Geronimo XML schema used by Geronimo application deployer. The geronimo-application.xml is the super set of all other deployment plans.

...

The default namespace of the above XML document is http://java.sun.com/xml/ns/javaee. The XML elements that do not have a namespace prefix belong to the default namespace.

In the RetrieveOrderInfoBean, the following code is used to look up the Datasource object and obtain a database connection.

...

...

The deployment descriptor of the OrderWEB.war is as follows.

...

...

...

The default namespace of the above XML document is http://java.sun.com/xml/ns/javaee. The XML elements that do not have a namespace prefix belong to the default namespace.

In the RetrieveOrder servlet, the following code is used to look up the ejb to retrieve the order details.

...

...

The deployment descriptor of the Order.ear is as follows.

...

...

The default namespace of the above XML document is http://java.sun.com/xml/ns/javaee. The XML elements that do not have a namespace prefix belong to the default namespace.

...

...

The default namespace of the above XML document is http://geronimo.apache.org/xml/ns/j2ee/application-2.0. The XML elements that do not have a namespace prefix belong to the default namespace.

...

Also, observe that, in the geronimo-application.xml, along with moduleId configuration for the EAR itself, there is a moduleId configuration for each web and ejb modules. If the above EAR file deployed on the server and the configurations are listed, the following output would be displayed on the console.

No FormatbgColor#000000borderStylesolid C:\Geronimo-2.1\bin>deploy.bat --user system --password manager list-modules Using GERONIMO_BASE: C:\Geronimo-2.1 Using GERONIMO_HOME: C:\Geronimo-2.1 Using GERONIMO_TMPDIR: var\temp Using JRE_HOME: C:\sun\jre Found 92 modules + Order/OrderEAR/5.0/car `-> OrderWEB.war `-> OrderEJB.jar + console.dbpool/OrderDS/1.0/rar

The moduleId Order/OrderEAR/5.0/car is the configuration for the Order.ear. The ejb module declares a dependency on the console.dbpool/OrderDS/1.0/rar configuration in <sys:dependencies> section. This is the moduleId of the database pool that connects to the DB2 database where the order details are stored.

...

The following is the deployment descriptor of the JEE application client module that looks up an ejb and calls a method on it. The ejb converts the Indian Rupess (Rs.) into American Dollars ($). The client sends a double value which is Indian Rupees to ejb. The ejb returns equivalent American Dollars as double value.

...

...

...

The default namespace of the above XML document is http://java.sun.com/xml/ns/javaee. The XML elements that do not have a namespace prefix belong to the default namespace. Hence, in the above XML document, all the XML elements belong to the default namespace.

The application client declares the ejb name ejb/Converter through <ejb-ref>> .. </ejb-ref> elements.

Following is the corresponding deployment plan of the JEE client module.

...

...

The default namespace of the above XML document is http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0. The XML elements that do not have a namespace prefix belong to the default namespace. Hence, in the above XML document, <application-client>, <ejb-ref> and <ref-name> elements belong to the default namespace.

Observe the various xml elements and schemas to which they belong. The plan defines the client environment and the server environment configurations. The server environment configuration runs in the server where as the client environment configuration runs in the client JVM. In the above plan, the ejb name ejb/Converter is mapped to ConverterBean ejb in the ConverterEAR.

The below is the client code that looks up the ejb and calls the method on it.

...

...

The META-INF/MANIFEST.MF file should contain the following entry for the client to run.

...

Do not forget to insert a new line after the Main-Class: entry in the MANIFEST.MF file.

...

The following command illustrates the packaging.
No FormatbgColor#000000borderStylesolid C:\temp\ConverterEJBClient>jar -cvf ConverterEJBClient.jar * added manifest adding: examples/(in = 0) (out= 0)(stored 0%) adding: examples/appclient/(in = 0) (out= 0)(stored 0%) adding: examples/appclient/client/(in = 0) (out= 0)(stored 0%) adding: examples/appclient/client/ConverterClient.class(in = 1716) (out= 936)(deflated 45%) adding: examples/appclient/Converter.class(in = 146) (out= 131)(deflated 10%) adding: META-INF/application-client.xml(in = 510) (out= 252)(deflated 50%) adding: META-INF/geronimo-application-client.xml(in = 2049) (out= 474)(deflated 76%) ignoring entry META-INF/MANIFEST.MF

The following commands illustrates the deployment and running of the client module.
No FormatbgColor
#000000borderStylesolid C:\\Geronimo-2.1\bin>deploy.bat --user system --password manager deploy C:\temp\ConverterEJBClient.jar Using GERONIMO_BASE: C:\Geronimo-2.1 Using GERONIMO_HOME: C:\Geronimo-2.1 Using GERONIMO_TMPDIR: var\temp Using JRE_HOME: C:\JDK\jre Deployed Converter/Converter-app-client-server/3.0/jar C:\Geronimo-2.1\bin>java -Djava.endorsed.dirs="C:\Geronimo-2.1\lib\endorsed" -jar C:\Geronimo-2.1\bin\client.jar Converter/Converter-app-client/3.0/jar 4000 Rs 4000.0 is 100.0 Dollars.

Message Driven Bean deployment plan.

Apache geronimo ships with ActiveMQ message broker and an inbound and outbound JMS resource adapter for the ActiveMQ broker. This sample illustrates deploying and running two MDBs that listen to a jms topic TextTopic. When the web client publishes a message to this topic, the two MDBs receive the message and process it. Because the message is published to the topic, all the configured listeners, in this case the two MDBs, receive a copy of the message. In addition to that, we will also illustrate how to deploy a JMS resource adapter within the application scope. Usually, the resource adapters are deployed at the server scope and can be used by all other applications as well. In this example, a JMS resource plan is embedded in the application deployment plan geronimo-application.xml and deployed while deploying the application archive.

...

...

The ejb-jar.xml declares the two MDBs sample.mdb.TextMessageBean1 and sample.mdb.TextMessageBean2 both listen to a javax.jms.Topic destination.

...

...

In the deployment plan openejb-jar.xml, the two MDBs are configured as end point listeners for the jms topic TextMessageTopic.

The code for the two MDBs are as follows.

...

...

After receiving the message, the MDBs just print the contents of the message.

The web client for the application is as follows.

...

...

The web client declares the javax.jms.TopicConnectionFactory and the topic to which the servlet has to publish the message. The names declared here are mapped to actual resources in the geronimo-web.xml as follows.

...

...

Please note that the jms/TopicConnectionFactory and jms/Topic/TextTopic are the names of the actual connection factory and jms topic. These are deployed by a jms resource plan embedded in the EAR's deployment plan as follows.

...

...

The plan for resource adapter is provided under <ext-module> xml elements. Also, the resource adapter archive (rar) file to be used to deploy the plan is mentioned using external-path xml element; the resource adapter plan follows these elements. The plan deploys{{ jms/TopicConnectionFactory}} and TextTopic.

...

...

The reference to resource archive file is provided using the following xml elements in the above plan.

...

The above pattern is the way how geronimo references various libraries available in the server repository. Any external libraries can also be uploaded to server repository using admin console portlet. After starting the server, click on Console Navigation => Services => Repository to display Repository Viewer portlet. In this portlet, users can upload required third party libraries by providing proper groupId, artifactId and version values for the libraries being uploaded. The activeMQ rar file is also available in the repository as org.apache.geronimo.modules/geronimo-activemq-ra/2.1/rar. Click on this link to get the usage instructions on how to reference this library in other modules.

The web client that look up the connection factory and topic and sends messages is as follows.

...

...

When the above servlet is accessed on a browser window as http://localhost:8080/MDBSampleWEB/Test?CustomerId=10&CustomerName=Phani, the following output is displayed in the server console.
No FormatbgColor#000000borderStylesolid ------------------------------------------- Received new message in TextMessageBean1 : Customer Info CustomerId : 10 CustomerName : Phani ------------------------------------------- ------------------------------------------- Received new message in TextMessageBean2 : Customer Info CustomerId : 10 CustomerName : Phani -------------------------------------------