You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 57 Next »

This article is provided a great deal of information for users to get an understanding of geronimo deployment plans for EJB. In this article will cover the structure, overview and elements of the EJB deployment plans. Basically this topic is a wide broad area to discuss and it should be updated on and on with the future enhancement of geronimo. Though this document is limited in scope, it has addressed the deployment plans of openejb-jar.xml in depth which helps the user to get an idea of what each element does in the openejb-jar.xml. The article covers areas such as how applications can refer the different resources and handling such scenarios.

This article is organized into the following sections :

1.0 Basic steps to Deploy EJB in Geronimo

Typically, there are several steps to be taken to deploy EJBs in Geronimo :

  1. First, it needs to create the EJB classes and interfaces.
  2. Create the standard ejb-jar.xml deployment descriptor.
  3. Create a Geronimo-specific openejb-jar.xml deployment plan.
  4. Package the EJBs and deployment descriptors into an EJB JAR, or a directory tree laid out like an EJB JAR.

Use the deployment tool described in deployment plan "The Deploy Tool" to deploy the EJB JAR (or an EAR containing the EJB JAR) into the server or else the use can use the geronimo web console for it.

Describing the Geronimo deployment plan for EJB

Geronimo deployment plan for an EJB JAR is an XML document called "openejb-jar.xml". This document is defined by the openejb-jar-2.0.xsd schema and can be found in the <geronimo-home>/schema/ subdirectory of the main Geronimo installation directory. The deployment plan for an EJB JAR may be included in the EJB JAR, in which case it should be named META-INF/openejb-jar.xml or included in an EAR (but outside of the EJB JAR) and referenced by an alt-dd element of the EAR deployment plan or else saved as a separate file and provided to the deploy tool when the EJB JAR module is deployed (though this does not work when the EJB JAR is in an EAR).

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:

openejb-jar
<openejb-jar
xmlns:openejb="http://www.openejb.org/xml/ns/openejb-jar-2.1"
    targetNamespace="http://www.openejb.org/xml/ns/openejb-jar-2.1"
    xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
    xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
    xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
    xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
    version="1.0">
...
</openejb-jar>

xmlns
The main namespace for the deployment plan, which should always be http://www.openejb.org/xml/ns/openejb-jar-2.1

xmlns:naming

A secondary namespace, used to identify the common elements for resolving EJB references, resource references, and Web services references. If any of those need to be resolved in the deployment plan, this attribute should be present, and should be set to http://geronimo.apache.org/xml/ns/naming-1.1

xmlns:security
A secondary namespace, used to identify the common elements for security configuration. If there are any security settings in the deployment plan, this attribute should be present, and should be set to http://geronimo.apache.org/xml/ns/security-1.1

xmlns:sys
A secondary namespace, used to identify the common elements for common libraries and module-scoped services. If there are any of those present in the deployment plan, this attribute should be present, and should be set to http://geronimo.apache.org/xml/ns/deployment-1.1

xmlns:pkgen
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

<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
        <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
                <dep:moduleId>
                        <dep:groupId>default</dep:groupId>
                        <dep:artifactId>BankEJB</dep:artifactId>
                        <dep:version>1.0</dep:version>
                        <dep:type>car</dep:type>
                </dep:moduleId>
                <dep:dependencies/>
                <dep:hidden-classes/>
                <dep:non-overridable-classes/>
        </dep:environment>
        <cmp-connection-factory>
                <resource-link>BankPool</resource-link>
        </cmp-connection-factory>
        <enterprise-beans>
                <session>
                        <ejb-name>BankManagerFacadeBean</ejb-name>
                        <jndi-name>org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean</jndi-name>
                        <ejb-ref>
                                <ref-name>ejb/Customer</ref-name>
                                <ejb-link>Customer</ejb-link>
                        </ejb-ref>
                        <ejb-ref>
                                <ref-name>ejb/Account</ref-name>
                                <ejb-link>Account</ejb-link>
                        </ejb-ref>
                        <ejb-ref>
                                <ref-name>ejb/ExchangeRate</ref-name>
                                <ejb-link>ExchangeRate</ejb-link>
                        </ejb-ref>
                </session>
                
                <entity>
                        <ejb-name>Account</ejb-name>
                        <local-jndi-name>AccountLocalEntity</local-jndi-name>
                        <table-name>Account</table-name>
                        
                        <cmp-field-mapping>
                                <cmp-field-name>accountNumber</cmp-field-name>
                                <table-column>ACC_NO</table-column>
                        </cmp-field-mapping>
                        
                        <cmp-field-mapping>
                                <cmp-field-name>accountType</cmp-field-name>
                                <table-column>ACC_TYPE</table-column>
                        </cmp-field-mapping>
                        
                        <cmp-field-mapping>
                                <cmp-field-name>customer</cmp-field-name>
                                <table-column>CUSTID_FK</table-column>
                        </cmp-field-mapping>
                        
                        <cmp-field-mapping>
                                <cmp-field-name>balance</cmp-field-name>
                                <table-column>BALANCE</table-column>
                        </cmp-field-mapping>
                        
                        <resource-ref>
                                <ref-name>jdbc/BankDataSource</ref-name>
                                <resource-link>BankPool</resource-link>
                        </resource-ref>
                </entity>
                
                <entity>
                        <ejb-name>Customer</ejb-name>
                        <local-jndi-name>CustomerLocalEntity</local-jndi-name>
                        <table-name>Customer</table-name>
                        
                        <cmp-field-mapping>
                                <cmp-field-name>customerId</cmp-field-name>
                                <table-column>CUST_ID</table-column>
                        </cmp-field-mapping>
                        
                        <cmp-field-mapping>
                                <cmp-field-name>customerName</cmp-field-name>
                                <table-column>CUST_NAME</table-column>
                        </cmp-field-mapping>
                        
                        <resource-ref>
                                <ref-name>jdbc/BankDataSource</ref-name>
                                <resource-link>BankPool</resource-link>
                        </resource-ref>
                </entity>
                
                <entity>
                        <ejb-name>ExchangeRate</ejb-name>
                        <local-jndi-name>ExchangeRate</local-jndi-name>
                        <resource-ref>
                                <ref-name>jdbc/BankDataSource</ref-name>
                                <resource-link>BankPool</resource-link>
                        </resource-ref>
                </entity>
        </enterprise-beans>

        <relationships>
                <ejb-relation>
                        <ejb-relation-name>Customer-Account</ejb-relation-name>
                        <ejb-relationship-role>
                                <ejb-relationship-role-name>Account-to-Customer</ejb-relationship-role-name>
                                <relationship-role-source>
                                        <ejb-name>Account</ejb-name>
                                </relationship-role-source>
                                <cmr-field>
                                        <cmr-field-name>customer</cmr-field-name>
                                </cmr-field>
                                <foreign-key-column-on-source/>
                                <role-mapping>
                                        <cmr-field-mapping>
                                                <key-column>CUST_ID</key-column>
                                                <foreign-key-column>CUSTID_FK</foreign-key-column>
                                        </cmr-field-mapping>
                                </role-mapping>
                        </ejb-relationship-role>
                </ejb-relation>

        </relationships>

</openejb-jar>

1.1 Geronimo EJB Deployment Plan Overview.

In a EJB deployment plan there are main attributes defined in the top.

configIdrequiting
A unique name identifying this module. If deployed as a standalone EJB JAR, this name is used to identify the module to the deployment tool (to start, stop, undeploy, or redeploy the EJB JAR).

parentId
Identifies the parent configuration for this EJB JAR (the value specified here should match the configId for that module). If deployed as a standalone EJB JAR, this can be used to make the EJB JAR depend on another module such as another standalone EJB JAR or a J2EE Connector (or it should otherwise be omitted or set to the usual parent for J2EE modules, geronimo/j2ee-server/1.0/car).

inverseClassloading
If set to true, the class loader for the EJB JAR tries to load a class before checking whether the class is available from its parent class loader. configId
A unique name identifying this module. If deployed as a standalone EJB JAR, this name is used to identify the module to the deployment tool (to start, stop, undeploy, or redeploy the EJB JAR).

parentId
Identifies the parent configuration for this EJB JAR (the value specified here should match the configId for that module). If deployed as a standalone EJB JAR, this can be used to make the EJB JAR depend on another module such as another standalone EJB JAR or a J2EE Connector (or it should otherwise be omitted or set to the usual parent for J2EE modules, geronimo/j2ee-server/1.0/car). If deployed as part of an EAR this is usually not necessary, as EAR configuration will be the parent of this module.

inverseClassloading
If set to true, the class loader for the EJB JAR tries to load a class before checking whether the class is available from its parent class loader. If omitted or set to false, the normal (check parent first) class loader delegation behavior is used

1.2 Typical contents of Geronimo EJB Deployment Plan

There are some typical contents of the Geronimo EJB Deployment Plan has been identified as and it has described follows

Security settings indicating which users and roles should be able to access secure EJBs or secure EJB methods
Details to resolve EJB references, resource references, and web services references declared by EJBs in the ejb-jar.xml deployment descriptor. This isn't always necessary for EJB references (which may be resolved using an ejb-link in the ejb-jar.xml) but generally is for the other types of references.
JNDI names for each EJB, used by remote clients attempting to connect to the EJB.
Web Services settings, for session beans exposed as web services.
Database pool, table, column, query, and relationship information for CMP Entity Beans.
JMS mapping information for Message-Driven Beans.
For the simplest EJB JARs these settings may not be required or the defaults may be sufficient, but in most cases the Geronimo EJB deployment plan will need a substantial amount of information.
As usual in other geronimo deployment plans open-ejb.jar has specific structure and element followed in an order.

1.3 Geronimo Deployment path settings

The elements in the classloader-infoGroup are used to customized the EJB JAR's class.There are four elements need to be discussed under class path settings.

import

Refers to another configuration deployed in the server. That configuration will be added as a parent of this one (a configuration may have more than one parent). The main effect is that the class loader for the EJB JAR will add the class loader for that configuration as a parent. Additionally, the parent configuration will be started before the EJB JAR.

dependency
Adds a third-party library to the class path for the EJB JAR. Any common libraries used in this manner should be located in a subdirectory of the repository/ directory of the main Geronimo installation.

hidden-classes

Lists packages or classes that may be in a parent class loader, but should not be exposed from there to the EJB JAR. This is typically used when the EJB JAR wants to use a different version of a library that one of its parent configurations (or Geronimo itself) uses.

non-overridable-classes

Lists packages or classes that the EJB JAR should always load from a parent class loader, and never load from its own class loader. This might be used to force an EJB to share the same instance of a common library with other applications or modules, even if they each include it in their own class path.

filter
Used to list classes or packages. The format is a comma-separated list of packages or fully-qualified class names (for example: javax.servlet,javax.ejb).

When considering the JMS and MDB Sample given(link the sample application) and it does not have any dependencies and imports.

<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
  xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1" 
  xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1" 
  xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
  <sys:environment>
    <sys:moduleId>
      <sys:groupId>samples</sys:groupId>
      <sys:artifactId>OrderEjb</sys:artifactId>
      <sys:version>1.0</sys:version>
      <sys:type>car</sys:type>
    </sys:moduleId>
    <sys:dependencies>
		<sys:dependency>
			<sys:groupId>geronimo</sys:groupId>
			<sys:artifactId>activemq-broker</sys:artifactId>
			<sys:version>1.1</sys:version>
			<sys:type>car</sys:type>
        </sys:dependency>
		<sys:dependency>
            <sys:groupId>samples</sys:groupId>
            <sys:artifactId>jms-resources</sys:artifactId>
            <sys:version>1.0</sys:version>
            <sys:type>rar</sys:type>
        </sys:dependency>
    </sys:dependencies>
    <sys:hidden-classes/>
    <sys:non-overridable-classes/>
  </sys:environment>

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

Working out deployment plans with samples

Deploying JAR containing Simple EJB application

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

HelloWorld
   |_ejbModule
   |          |_org.geronimo.ejbsample
   |          |                 |_HelloBean
   |          |                 |_HelloHome
   |          |                 |_HelloObject
   |          |
   |          |_org.geronimo.ejbsample.client
   |                                    |_HelloWorld
   |_META-INF
   |      |_ejb-jar.xml
   |      |_openejb-jar.xml
   |
   |_dist
   |_build
   |_build.xml

Here is the ejb-jar.xml for the above sample

ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" 
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
  <enterprise-beans>
    <session>
      <ejb-name>HelloBean</ejb-name>
      <home>org.geronimo.ejbsample.HelloHome</home>
      <remote>org.geronimo.ejbsample.HelloObject</remote>
      <ejb-class>org.geronimo.ejbsample.HelloBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
    </session>
  </enterprise-beans>
  <assembly-descriptor>
    <container-transaction>
      <method>
        <ejb-name>HelloBean</ejb-name>
        <method-name>*</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
    </container-transaction>
  </assembly-descriptor>
</ejb-jar>

Geronimo v1.1 deployment plan for the above sample

openejb.jar
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
  <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
    <dep:moduleId>
      <dep:groupId>org.geronimo.</dep:groupId>
      <dep:artifactId>ejbsample</dep:artifactId>
      <dep:version>1.0</dep:version>
      <dep:type>car</dep:type>
    </dep:moduleId>
    <dep:dependencies/>
    <dep:hidden-classes/>
    <dep:non-overridable-classes/>
  </dep:environment>
  <enterprise-beans>
    <session>
      <ejb-name>HelloBean</ejb-name>
      <jndi-name>org.geronimo.ejbsample.HomeBean</jndi-name>
    </session>
  </enterprise-beans>
</openejb-jar>

Steps to deploying the sample

There are two ways in which the sample can be deployed :-

1. The sample can be built from scratch using the build.xml and editing the geronimo_home as your directory. Obtain the helloworld-ejbs.jar from the dist directory and use the Geronimo web console. Browse for the helloworld-ejbs.jar file and click on the Install button.

2.Use the following command line code to deploy the application.

 

Running the Client to test the HelloWorld EJB service

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.

< <app-home>/org/geronimo/ejbsampleclient> >java HelloWorld

You will see the "Hello world" print on your command line
HelloWorld/org/geronimo/ejbsampleclient>
  Hello World!

Working with different EJB types

1.4 Common settings for CMP Entity beans

There are few settings for CMP Entity beans in a geronimo EJB deployment plan and following are element we consider to set values.

cmp-connection-factory

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

<cmp-connection-factory>
		<resource-link>BankPool</resource-link>
	</cmp-connection-factory>

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.

db-syntax-factory
The name of a class that knows how to customize CMP SQL statements for a particular database product. This must be the fully-qualified class name of a class that implements org.tranql.sql.DBSyntaxFactory. The default is for the Derby database, though this may work for other database products too.

enforce-foreign-key-constraints

This is effectively a true/false element – if it's present that means true, and if it's not present, that means false. If true, then Geronimo will make a special effort to execute insert, update, and delete statements in an order consistent with the foreign keys between tables. If false, then Geronimo will execute statements in any order, though still within the same transaction. This element should be present if the underlying database enforces foreign keys at the moment a statement is executed instead of at the end of the transaction.

1.5 Settings for EJB Session beans

Mainly following elements needs to be set up

ejb-name
Identifies the EJB that these settings apply to. This should match the ejb-name for the EJB in ejb-jar.xml.

jndi-name

The Home interface for the EJB is registered in JNDI at the address specified here. This global JNDI name is used by application clients to connect to this EJB, as well as by CORBA clients if this EJB is exposed via CORBA. It is only meaningful if the EJB has a (remote) Home interface.

local-jndi-name

The LocalHome interface for the EJB is registered in JNDI at the address specified here. It is only meaningful if the EJB has a LocalHome interface. Note that the official Geronimo distributions do not allow access to local EJBs via JNDI (making this setting irrelevant), but a custom Geronimo build may.

tssGroup
This is a set of elements that contains CORBA security settings, for EJBs exposed as CORBA objects. It is not necessary if the EJB will not be accessed via CORBA.

jndiEnvironmentRefsGroup
A set of elements that handle resolving references declared by the current Session bean.For an example EJB references, Resource references, and Web Service references can be handled.

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

openejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
	<dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
		<dep:moduleId>
			<dep:groupId>default</dep:groupId>
			<dep:artifactId>BankEJB</dep:artifactId>
			<dep:version>1.0</dep:version>
			<dep:type>car</dep:type>
		</dep:moduleId>
		<dep:dependencies/>
		<dep:hidden-classes/>
		<dep:non-overridable-classes/>
	</dep:environment>
	<cmp-connection-factory>
		<resource-link>BankPool</resource-link>
	</cmp-connection-factory>
	<enterprise-beans>
		<session>
			<ejb-name>BankManagerFacadeBean</ejb-name>
			<jndi-name>org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean</jndi-name>
			<ejb-ref>
				<ref-name>ejb/Customer</ref-name>
				<ejb-link>Customer</ejb-link>
			</ejb-ref>
			<ejb-ref>
				<ref-name>ejb/Account</ref-name>
				<ejb-link>Account</ejb-link>
			</ejb-ref>
			<ejb-ref>
				<ref-name>ejb/ExchangeRate</ref-name>
				<ejb-link>ExchangeRate</ejb-link>
			</ejb-ref>
		</session>
	  	
		<entity>
			<ejb-name>Account</ejb-name>
			<local-jndi-name>AccountLocalEntity</local-jndi-name>
			<table-name>Account</table-name>
			
			<cmp-field-mapping>
				<cmp-field-name>accountNumber</cmp-field-name>
				<table-column>ACC_NO</table-column>
			</cmp-field-mapping>
			
			<cmp-field-mapping>
				<cmp-field-name>accountType</cmp-field-name>
				<table-column>ACC_TYPE</table-column>
			</cmp-field-mapping>
			
			<cmp-field-mapping>
				<cmp-field-name>customer</cmp-field-name>
				<table-column>CUSTID_FK</table-column>
			</cmp-field-mapping>
			
			<cmp-field-mapping>
				<cmp-field-name>balance</cmp-field-name>
				<table-column>BALANCE</table-column>
			</cmp-field-mapping>
			
			<resource-ref>
				<ref-name>jdbc/BankDataSource</ref-name>
				<resource-link>BankPool</resource-link>
			</resource-ref>
		</entity>
	  	
		<entity>
			<ejb-name>Customer</ejb-name>
			<local-jndi-name>CustomerLocalEntity</local-jndi-name>
			<table-name>Customer</table-name>
			
			<cmp-field-mapping>
				<cmp-field-name>customerId</cmp-field-name>
				<table-column>CUST_ID</table-column>
			</cmp-field-mapping>
			
			<cmp-field-mapping>
				<cmp-field-name>customerName</cmp-field-name>
				<table-column>CUST_NAME</table-column>
			</cmp-field-mapping>
			
			<resource-ref>
				<ref-name>jdbc/BankDataSource</ref-name>
				<resource-link>BankPool</resource-link>
			</resource-ref>
		</entity>
	  	
		<entity>
			<ejb-name>ExchangeRate</ejb-name>
			<local-jndi-name>ExchangeRate</local-jndi-name>
			<resource-ref>
				<ref-name>jdbc/BankDataSource</ref-name>
				<resource-link>BankPool</resource-link>
			</resource-ref>
		</entity>
	</enterprise-beans>

	<relationships>
		<ejb-relation>
			<ejb-relation-name>Customer-Account</ejb-relation-name>
			<ejb-relationship-role>
				<ejb-relationship-role-name>Account-to-Customer</ejb-relationship-role-name>
				<relationship-role-source>
					<ejb-name>Account</ejb-name>
				</relationship-role-source>
				<cmr-field>
					<cmr-field-name>customer</cmr-field-name>
				</cmr-field>
				<foreign-key-column-on-source/>
				<role-mapping>
					<cmr-field-mapping>
						<key-column>CUST_ID</key-column>
						<foreign-key-column>CUSTID_FK</foreign-key-column>
					</cmr-field-mapping>
				</role-mapping>
			</ejb-relationship-role>
		</ejb-relation>

	</relationships>

</openejb-jar>

The following piece of code has excerpt from above openejb-jar.xml and showed how session bean defined in it.
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>


<session>
	<ejb-name>BankManagerFacadeBean</ejb-name>
		<jndi-name>org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean</jndi-name>
	        	<ejb-ref>
				<ref-name>ejb/Customer</ref-name>
				<ejb-link>Customer</ejb-link>
			</ejb-ref>
			<ejb-ref>
				<ref-name>ejb/Account</ref-name>
				<ejb-link>Account</ejb-link>
			</ejb-ref>
			<ejb-ref>
				<ref-name>ejb/ExchangeRate</ref-name>
				<ejb-link>ExchangeRate</ejb-link>
			</ejb-ref>
		</session>
	  	

Common settings for Entity Beans

Entity Beans settings can include JNDI names used by remote clients,CMP settings, and haven't tested COBRA configurations and resolving references.There are set of elements to be configured in the openejb-jar.xml.The following code piece is excerpt from the Sample Application and which shows how entity bean has been implemented in the deployment plans.

ejb-name This ejb-name element identifies the EJB that these settings apply to. This should match the ejb-name for the EJB in ejb-jar.xml

jndi-name The Home interface for the EJB is registered in JNDI at the address specified here. This global JNDI name is used by application clients to connect to this EJB.It is only meaningful if the EJB has a (remote) Home interface.

local-jndi-name The LocalHome interface for the EJB is registered in JNDI at the address specified here. It is only meaningful if the EJB has a LocalHome interface. Note that the official Geronimo distributions do not allow access to local EJBs via JNDI (making this setting irrelevant), but a custom Geronimo build may.

tssGroup This is a set of elements that contains CORBA security settings, for EJBs exposed as CORBA objects. (It has not Tested this elements in practically)

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

....
       <entity>
             <ejb-name>ExchangeRate</ejb-name>
                 <local-jndi-name>ExchangeRate</local-jndi-name>
                      <resource-ref>
                          <ref-name>jdbc/BankDataSource</ref-name>
                          <resource-link>BankPool</resource-link>
                      </resource-ref>
       </entity>
....

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

Common Settings for Message-driven bean

Message-driven bean settings include mapping the MDB to a specific message destination (usually a JMS Topic or Queue), as well as resolving references to other EJBs, resources, or web services.The geronimo user guide provides a sample applicationLink the sample which elaborate how to deploy a MDB in geronimo.There are common settings to be done in the deployment plan in order to achieve this.

ejb-name Identifies the EJB that these settings apply to. This should match the ejb-name for the EJB in ejb-jar.xml.

resource-adapter The resource-adapter element identifies the resource adapter that this message-driven bean connects to. This is typically a JMS server, meaning ActiveMQ for the default Geronimo JMS provider.It identifies the resource adapter instance that this MDB should use to connect to its destination. For example, a specific ActiveMQ broker may have several resource adapter instances set up, with different authentication settings, and this identifies the specific instance to use.
There are several ways to identify the resource adapter. One is to specify the component by a simple name (resource-link), while the other is to use a more complex GBean Name (target-name, or the individual components in the objectNameGroup). The resource-link handles most common resource situations (a JMS resource adapter deployed as part of the same EAR or in the top level of the server) while the target-name or objectNameGroup can be used for any resource. This might be important if, for example, two resource adapter deployments use the same name, so the resource-link does not uniquely identify one and it must be fully-qualified.This can be used to identify any resource adapter in the same EAR or at the top level in the server. The value specified here should match the resourceadapter-name specified for the resource adapter instance in its Geronimo deployment plan.

target-name

A way to specify any resource adapter running in the server. This should be a GBean Name identifying the resource, such as geronimo.server:J2EEServer=geronimo,J2EEApplication=null, JCAResource=MyJMS,j2eeType=JCAResourceAdapter,name=JMS_RA

activation-config
Holds any configuration data (in the form of name/value pairs) required by the resource adapter in order to supply messages to the MDB.

jndiEnvironmentRefsGroup
A set of elements that handle resolving references declared for the current message-driven bean (including EJB references, Resource references, and Web Service references).

The sample application given in the user guide (link it to the JMS and MDB sample) demonstrates how to implement the MDB in geronimo.Basically the Business overview of this application is the following. Order processing application has two defined message queues to receive orders and consignments. Order requests can be generated and sent via the company's web application. When order requests are received to the order queue, a MDB will be triggered. It will carry out the next level of order request processing by saving those requests in to a server repository. Those saved order requests will be processed by a company employee later.

In order to deploy a JMS/MDB with geronio 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

 JMS_resource_plan.xml
<?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>samples</dep:groupId>
            <dep:artifactId>jms-resources</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>activemq-broker</dep:artifactId>
                <dep:type>car</dep:type>
            </dep:dependency>
        </dep:dependencies>
    </dep:environment>
    <resourceadapter>
        <resourceadapter-instance>
            <resourceadapter-name>CommonConnectionFactory</resourceadapter-name>
            <config-property-setting name="Password">geronimo</config-property-setting>
            <config-property-setting name="UserName">geronimo</config-property-setting>
            <nam:workmanager xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1">
                <nam:gbean-link>DefaultWorkManager</nam:gbean-link>
            </nam:workmanager>
        </resourceadapter-instance>
        <outbound-resourceadapter>
            <connection-definition>
               <connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface>
                <connectiondefinition-instance>
                    <name>CommonConnectionFactory</name>
                    <connectionmanager>
                        <xa-transaction>
                            <transaction-caching/>
                        </xa-transaction>
                        <single-pool>
                            <match-one/>
                        </single-pool>
                    </connectionmanager>
                </connectiondefinition-instance>
            </connection-definition>
        </outbound-resourceadapter>
    </resourceadapter>
    <adminobject>
        <adminobject-interface>javax.jms.Queue</adminobject-interface>
        <adminobject-class>org.activemq.message.ActiveMQQueue</adminobject-class>
        <adminobject-instance>
            <message-destination-name>OrderQueue</message-destination-name>
            <config-property-setting name="PhysicalName">OrderQueue</config-property-setting>
        </adminobject-instance>
		<adminobject-instance>
            <message-destination-name>ConsignmentQueue</message-destination-name>
            <config-property-setting name="PhysicalName">ConsignmentQueue</config-property-setting>
        </adminobject-instance>
    </adminobject>
    <adminobject>
        <adminobject-interface>javax.jms.Topic</adminobject-interface>
        <adminobject-class>org.activemq.message.ActiveMQTopic</adminobject-class>
    </adminobject>
</connector>

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 sind 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 avialable 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)

openejb-jar.xml
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1" 
 xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1" 
 xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1" 
 xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
  <sys:environment>
    <sys:moduleId>
      <sys:groupId>samples</sys:groupId>
      <sys:artifactId>OrderEjb</sys:artifactId>
      <sys:version>1.0</sys:version>
      <sys:type>car</sys:type>
    </sys:moduleId>
    <sys:dependencies>
		<sys:dependency>
			<sys:groupId>geronimo</sys:groupId>
			<sys:artifactId>activemq-broker</sys:artifactId>
			<sys:type>car</sys:type>
        </sys:dependency>
		<sys:dependency>
            <sys:groupId>samples</sys:groupId>
            <sys:artifactId>jms-resources</sys:artifactId>
            <sys:version>1.0</sys:version>
            <sys:type>rar</sys:type>
        </sys:dependency>
    </sys:dependencies>
    <sys:hidden-classes/>
    <sys:non-overridable-classes/>
  </sys:environment>
  <enterprise-beans>
    <message-driven>
      <ejb-name>OrderRecvMDB</ejb-name>
		<resource-adapter>
			<resource-link>CommonConnectionFactory</resource-link>
      	</resource-adapter>
		<activation-config>
		  <activation-config-property>
		    <activation-config-property-name>destination</activation-config-property-name>
		    <activation-config-property-value>OrderQueue</activation-config-property-value>
		  </activation-config-property>
		  <activation-config-property>
		    <activation-config-property-name>destinationType</activation-config-property-name>
		    <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
		  </activation-config-property>
		</activation-config>
    </message-driven>
  </enterprise-beans>
</openejb-jar>

According to openejb-jar.xml it's shown 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.

<sys:dependencies>
		<sys:dependency>
			<sys:groupId>geronimo</sys:groupId>
			<sys:artifactId>activemq-broker</sys:artifactId>
			<sys:type>car</sys:type>
        </sys:dependency>
		<sys:dependency>
            <sys:groupId>samples</sys:groupId>
            <sys:artifactId>jms-resources</sys:artifactId>
            <sys:version>1.0</sys:version>
            <sys:type>rar</sys:type>
        </sys:dependency>
    </sys:dependencies>

Resolving References from EJBs

EJBs can declare references to other EJBs either local or as an interfaces remotely.These resources can be various types (database pools or JMS connection factories) to message destinations, and to web services. As in most cases, the references are declared in the ejb-jar.xml deployment descriptor, and those references are resolved to specific targets in the Geronimo openejb-jar.xml deployment plan.

This article will be discussing how the various types of references are resolved in EJB Applications with Geronimo server. These are applicable to all EJB types (Session, Entity, and Message-Driven) All of EJB types can declare references of any of these types.

Common Resource Mapping Elements

As it's mentioned earlier all the EJB types can declare references of any type using common resource Mapping elements.Therefore these elements have defined as common.Following diagram shows how these elements are organized in the xml graphical representation.

note:Image need to be draw and uploaded.

domain

The domain name portion of the GBean Name identifying the EJB or resource to map to. This should usually be geronimo.server

server

The J2EE Server portion of the GBean Name identifying the EJB or resource to map to. This should usually be geronimo, and if not specified, it defaults to the name of the JSR-77 J2EEServer that was configured for the deployer GBean that's deploying the current module
application

The name of the application that the target EJB or resource is defined by the application. If the target module was deployed standalone, this would be null. If it was deployed as part of an EAR, this should be the application-name specified for the EAR, or the moduleId if no application-name was specified.

module

The modulesID of the module that the target EJB or resource is in.

type

Should identify the type of the EJB or resource that this is pointing to. For EJBs, this should be one of StatefulSessionBean, StatelessSessionBean, EntityBean, or MessageDrivenBean, depending on the type of the target EJB.

name
The JSR-77 name of the target object. This would be the ejb-name for an EJB

  • No labels