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

...

excerptINLINE

Geronimo uses OpenEJB container for providing ejb services. An EJB application requires ejb-jar.xml as deployment descriptor and openejb-jar.xml as deployment plan.

...

The openejb-jar.xml file contains deployment plan for ejb modules. In the openejb-jar.xml file, the application deployer maps the security roles, ejb names, database resources, JMS resources, etc. declared in ejb-jar.xml file to corresponding entities deployed in the server. In addition to that, if there are any ejb container specific configurations to be done, the required settings are configured as well here. If the ejb module depends on any third party libraries or other services running in the server, all these third party libraries and the services are specified in the openejb-jar.xml file. Some ejb applications require class loading requirements different from the default class loading behavior. The openejb-jar.xml file allows application deployer to configure this as well. There are many more configurations that could be done through openejb-jar.xml file depending on the needs of the ejb application. The following sections briefly explain how openejb-jar.xml file can be used to configure the ejb container and ejb applications.

...

Sample plan for a SSB application

...

...

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

...

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=PhaniImage Removed, the following output is displayed in the server console.
No FormatborderStylesolid ------------------------------------------- Received new message in TextMessageBean1 : Customer Info CustomerId : 10 CustomerName : Phani ------------------------------------------- ------------------------------------------- Received new message in TextMessageBean2 : Customer Info CustomerId : 10 CustomerName : Phani -------------------------------------------