...
top Anchor
This article provides a great deal of information for users to get an understanding of Geronimo deployment plans for EJBs. This article covers the structure, overview and elements of EJB deployment plans. This topic is a broad area to discuss and this page should be updated constantly with the future enhancement of Geronimo. Though this document is limited in scope, it addresses the deployment plans of openejb-jar.xml in depth which will help the user to get an understanding of what each element does in the openejb-jar.xml. The article covers how applications can refer to different resources and handling such scenarios.
...
The deployment plan should always use the OpenEJB namespace, and it typically requires elements from the Geronimo Naming, Geronimo Security, and Geronimo System namespaces. Additionally, it has a required attribute to identify its configuration name, and an optional attribute to select a parent configuration. A typical deployment for openejb-jar.xml can be presented as follows:
...
xmlns
The main namespace for the deployment plan, which should always be http://www.openejb.org/xml/ns/openejb-jar-2.1
...
A secondary namespace, used to identify the common elements for configuring automatic primary key generation for CMP entity beans (such as, using a sequence or auto-increment column). If there are any primary key generators present in the deployment plan, this attribute should be present, and should be set to http://www.openejb.org/xml/ns/pkgen-2.0
...
...
2.1 Geronimo EJB Deployment Plan overview
...
When considering the JMS and MDB Sample given(link the sample application) and it does not have any dependencies and imports.
...
Here the dependencies are defined here references the sample JMS resource since the application and activemq-broker which is in /repository/activemq-broker/1.1/rar
...
This section will cover Geronimo v1.1 deployment plan for the simple helloworld EJB.
Here is the folder structure for the above simple application.Sample Application is available to download here
HelloWorld ejb Sample
...
...
Here is the ejb-jar.xml for the above sample :
...
...
Geronimo v1.1 deployment plan for the above sample
...
...
Steps to deploying the sample
...
org.geronimo.ejbsample.client.HelloWorld.java is the client code for the above application. Set the necessary class path to run client in your environment.
No Format
You will see the "Hello world" print on your command line
noformat
2.2.2 Working with different EJB types
...
This is specifies a JDBC connection pool that should be used by CMP entity beans to connect to the database. There are several styles available to refer to the connection pool.The cmp-connection-factory element points to a database pool using the same syntax a resource reference uses. There are several ways to identify the database pool. One is to specify the component by a simple name (resource-link), while the other is to use a more complex
ObjectName (target-name, or the individual components in the objectNameGroup). The resource-link handles most common resource situations (JDBC pools deployed as J2EE connectors in the same application or deployed standalone in the same server) while the target-name or objectNameGroup can be used for any
...
ejb-ql-compiler-factory
The name of a class that knows how to translate EJB-QL queries into SQL statements for a particular database product. This must be the fully-qualified class name of a class that implements org.tranql.sql.EJBQLCompilerFactory. The default is for the Derby database, though this may work for other database products too.
...
The following openejb-jar.xml has taken from the http://cwiki.apache.org/GMOxDOC11/ejb-sample-application.html
This example is using a EJB session bean and how it has implemented inside the openejb-jar.xml
...
The following piece of code has excerpt from above openejb-jar.xml and shows how the session bean is defined.
BankManagerFacadeBean is Stateless Session Bean which is acting as a service class for different application clients.It's jndi-name attribute is assigned to org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean Then the <ejb-ref> tag is used to refer the other dependent ejbs.In this case <ejb-ref> tag has two sub elements which are <ref-name> and the <ejb-name>
...
...
Common Settings for EJB Entity beans
...
This is a set of elements that handle resolving references declared by the current Session bean (including EJB references, Resource references, and Web Service references)and this group is common to all EJB types.
...
...
Considering the above piece of code under the <entity> tag <ejb name> is assigned for the relevant EJB entity bean.Since this ExchangeRate has a LocalHome interface <local-jndi-name> the EJB is registered in JNDI at the address specified as ExchangeRate .Under the <resource-ref> tags
...
In order to deploy a JMS/MDB with Geronimo it's required to create a JMS resource plan.The purpose of creating the JMS plan is that from the geronimo server end you will be accessing JMS/MDB resource using this plan which will define all the definitions for the connection factories and the Queues/Topics
...
...
Geronimo web console provides the needful to create a JMS resource plan structure and it's required to fill your bunisess logic to map to fill your requirements.Once you log in to the web console in your left hand side navigation you will find a JMS resource link under services.In this application there is a MDB that will listen on OrderQueue. openejb-jar.xml defines Geronimo specific JMS resource services available of that MDB. It links OrderRecv MDB with OrderQueue via CommonConnectionFactory.This Article will be discussing further details of the relationship of the JMS resource plan and the openejb-jar.xml in Resolving references session(link this to the topic)
...
...
According to openejb-jar.xml, it shows how the Geronimo resources are set as dependencies in order to access in the
EJB applications.Basically "activemq-broker" and "jms-resources" are the two dependencies comes with Geronimo server to use in MDB and JMS applications.
...
2.3 Resolving References from EJB
...
objectNameGroup is basically spliting out all the components But this element holds a single GBean Name containing all that information required to identify the EJB. This may be used to map an EJB in a different application. It would typically look like geronimo.server:J2EEApplication=ear-name,EJBModule=ejb-jar-name.jar, J2EEServer=geronimo,j2eeType=StatelessSessionBean,name=EJBName
Sample Code
...
When considering a typical admin object(such as a JMS topic or queue), the type should be JCAAdminObject and the name should match the message-destination-name for the admin object in the geronimo deployment plan for the JMS resource adapter.
...
The Scenario of the Sample is a Web Client(JSP) which locate and access a EJB by referring it locally.Simply it has used home interface to locate the EJB(service) and the remote interface has used to invoke methods on the EJB. The remote interface is just like a ordinary Remote Method Invocation interface (RMI). This EJB service is used only by the JSP web client which is run in the same Geronimo server (same JVM). Let's discuss how the EJB locally in deployment plans
...
...
As above shown in the web.xml file <ejb-local-ref> tag has used to define and set the values for locally referring EJB interfaces MyTimeLocalHome and MyTimeLocal.As you can see in the following geronimo-web.xml has not defined any entry for it that means for there is not server specific entry need to be define for a EJB reference.
...
In the ejb-jar.xml shows the normal deployment descriptor entries as usual for any server deployment.
...
As you already know openejb-jar.xml is the Geronimo specific deployment plan to deploy an EJB on Geronimo server.The following peice of code has been excerpt from the above to discuss further.The session bean is defined by giving the information for the client access.Note that ref-name=ejb/MyTimeBean is the same that clients use to lookup for the EJB. ejb-link=MyTimeBean in the openejb-jar.xml is the same for the ejb-name=MyTimeBean in ejb-jar.xml. The ejb-link and the ejb-name must be the same and then only a client will locate the EJB.
...
Resource References
In EJB applications require to refer many external resources typically JDBC resources,JMS resources or URLS.The geronimo deployment plan for EJB (openejb-jar.xml) handles such situations using the resource-ref .This element is used to map resource references to specific resources available in the geronimo server itself. The elements available for mapping resource references are defined as follows and it has used to some excerpt codes from the sample application to demonstrate these elements.Therefore consider the following openejb-jar.xml in the http://cwiki.apache.org/GMOxDOC11/ejb-sample-application.html
...
ref-name
Each resource reference must have a ref-name, which is used to match the definition in the openejb-jar.xml to the resource reference in ejb-jar.xml. Specifically, the value here must match the res-ref-name in the resource-ref in ejb-jar.xml.
...
objectNameGroup
This element can refer to the resource deployed in Geronimo using the syntax described in "Common Resource Mapping Elements". For a typical connection factory (such as a JDBC pool or JMS connection factory), the type should be JCAManagedConnectionFactory and the name should match the value of the connectiondefinition-instance/name element in the Geronimo deployment plan for the resource adapter (or the name selected for the resource when deploying it through the console). Note: other resource types may use different types and names.
...
This element can be used to identify any resource deployed as a J2EE connector (including JDBC pools and JMS connection factories). The value specified here should match the connectiondefinition-instance/name element in the Geronimo deployment plan for the connector.
...
...
This BankPool is an XML file which is the Geronimo data base plan created using geronimo(Debery has integrated with Geronimo to use as a Data Base resource) data base manager. Therefore, this has been deployed in the Geronimo server itself and resource-link tag will provide the access of it to the application.
...
This section will be covered how to resolve JBM references from EJB in geronimo.It's used the JMS sample application in the Uder Guide to demonstrate the deployment plans configurations in order to use JMS in applications(http://cwiki.apache.org/GMOxDOC11/jms-and-mdb-sample-application.html) JMS resource can be a topic or queue which need to be configured specifically in the ejb-jar.xml file, as shown below. In this example it has been generated using Xdoclet at the build time.
...
This sample application refers a JMS resource from the geronimo server and as you can see in the above ejb-jar.xml,following entried are used to configure it in ejb-jar.xml.This ejb-jar.xml was generated uisng xdoclet.And seems it has been limited to gernerate the primary needs of configuring JMS entries in the ejb-jar.xml
...
Message Listener allows a listener to be notified when a message arrives. Contrary to the pull-style of channels, some building blocks (e.g., PullPushAdapter) provide an event-like, push-style message delivery model. In this case, the entity to be notified of message reception needs to provide a callback to be invoked whenever a message has been received. The MessageListener interface provides a method to do so
...
Now the turn to see how this JMS resource has been configured on Geronimo specific deployment plan(openejb-jar.xml).Note that the segment of dependencies and message-driven has done it.First considering the setting for dependencies segment of the openejb-jar.xml,the JMS resources of the geronimo server and the deployed JMS resource plan have refered in it.artifactId=activemq-broker is the entry to make available( to the application)the JMS resource in the geronimo server itself.The second dependency setting is artifactId=jms-resources and jms-resources is the name of the JMS plan which refered by the application.This is a XML file which can be generated using Geronimo web console and should be already deployed in the server.
...
For reference, here's a snippet from a JMS connector deployment plan that matches the EJB JAR configuration above and this can be generated using the geronimo web console.One can identify the <moduleId> ,<dependency> and <adminobject> are mapped the ejb-jar.xml.
...
If the <adminoject-interface> is used to identify the type of JMS resource interface which has been used(Queue)and <adminobject-instance> segment is configured the JMS resource which is already deployed in the server(OrderQueue) and it's configuration property name setting (Phisical name).If you are generating using the geronimo web console,the wizard will ask for the values for all of these and the plan will be generated for at the end.
...
Following openejb-jar.xml has taken from the http://cwiki.apache.org/GMOxDOC11/ejb-sample-application.html.It has defined the dependencies in the <environment> segment and <cmp-connection-factory> is set to the Data Base plan.
...
...
Let's consider the CMP mapping implementation of the following code which is excerpt from the above openejb-jar.xml
...
Each DataBase mapping are configured with in the <cmp-field-mapping> and <cmp-field-mapping> is set to the customerId which is deployment plan specific reference for the name of the data field."CUS_ID" is the actual name of the data base field in the DataBase.
...