ejb3

EJB Deployment Descriptor Example

1. Introduction

Deployment descriptor is the file which tells the EJB server that which classes make up the bean implementation, the home interface and the remote interface. it also indicates the behaviour of one EJB with other. The deployment descriptor is generally called as ejb-jar.xml and is in the directory META-INF of the client application.

This is the main deployment descriptor that contains most of the information about the bean: the bean identification, security roles, transaction demarcation, and any optional environment definition.

Enterprise JavaBean components are deployed using a ejb-jar.xml deployment descriptor file, which must exist in the EJB module. The following text provide details on each section of the descriptor.

2. EJB Example

This section contains examples of complete deployment descriptors for specifying the behaviour of EJBs.

2.1 Complete deployment descriptor

The following ejb-jar.xml file contains a complete specification for a series of EJBs, including tags for security, transactions, resource injection, references, callbacks, callback listeners, interceptors, etc.

<ejb-jar> 
   <description>jBoss test application </description>
   <display-name>Test</display-name>
   <enterprise-beans>
      <session>
         <ejb-name>Teller</ejb-name>
         <remote>org.jboss.ejb3.test.bank.Teller</remote>
         <ejb-class>org.jboss.ejb3.test.bank.TellerBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
         <ejb-ref>
            <ejb-ref-name>ejb/Bank</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <remote>org.jboss.ejb3.test.bank.Bank</remote>
            <ejb-link>Bank</ejb-link>
            <injection-target>bank</injection-target>
         </ejb-ref>
         <resource-ref>
             <res-ref-name>java:/TransactionManager</res-ref-name>
             <res-type>javax.transaction.TransactionManager</res-type>
             <res-auth>Container</res-auth>
             <res-sharing-scope>Shareable</res-sharing-scope>
             <injection-target>setTransactionManager</injection-target>
         </resource-ref>
         <resource-ref>
             <res-ref-name></res-ref-name>
             <res-type>javax.ejb.TimerService</res-type>
             <res-auth>Container</res-auth>
             <res-sharing-scope>Shareable</res-sharing-scope>
             <injection-target>ts</injection-target>
         </resource-ref>
         <security-identity>
            <run-as>
               <role-name>bankTeller</role-name>
            </run-as>
         </security-identity>
      </session>
      <session>
         <ejb-name>Bank</ejb-name>
         <remote>org.jboss.ejb3.test.bank.Bank</remote>
         <ejb-class>org.jboss.ejb3.test.bank.BankBean</ejb-class>
         <session-type>Stateful</session-type>
         <transaction-type>Container</transaction-type>
         <env-entry>
            <env-entry-name>id</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <env-entry-value>5678</env-entry-value>
         </env-entry>
         <resource-ref>
            <res-ref-name>java:DefaultDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
            <injection-target>customerDb</injection-target>
         </resource-ref>
         <interceptor>org.jboss.ejb3.test.bank.FirstInterceptor</interceptor>
         <interceptor>org.jboss.ejb3.test.bank.SecondInterceptor</interceptor> 
         <callback-listener>org.jboss.ejb3.test.bank.ExternalCallbackListener</callback-listener>
      </session>
   </enterprise-beans>
   <assembly-descriptor>
      <callback>
         <annotation>PostConstruct</annotation>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>postConstruct</method-name>
         </method>
      </callback> 
      <remove-list>
         <method>
            <ejb-name>Bank</ejb-name>
            <method-name>remove</method-name>
         </method>
      </remove-list> 
      <init-list>
         <method>
            <ejb-name>Bank</ejb-name>
            <method-name>init</method-name>
         </method>
      </init-list> 
      <security-role>
         <role-name>bankCustomer</role-name>
      </security-role>
      <security-role>
         <role-name>bankTeller</role-name>
      </security-role>
      <method-permission>
         <role-name>bankCustomer</role-name>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>greetChecked</method-name>
         </method>
      </method-permission>
      <method-permission>
         <unchecked/>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>greetUnchecked</method-name>
         </method>
      </method-permission>
      <method-permission>
         <role-name>bankTeller</role-name>
         <method>
            <ejb-name>Bank</ejb-name>
            <method-name>getCustomerId</method-name>
         </method>
         <method>
            <ejb-name>Bank</ejb-name>
            <method-name>storeCustomerId</method-name>
         </method>
      </method-permission>
      <container-transaction>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>greetWithNotSupportedTransaction</method-name>
         </method>
         <trans-attribute>NotSupported</trans-attribute>
      </container-transaction>
      <container-transaction>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>greetWithRequiredTransaction</method-name>
            <method-params>
               <method-param>java.lang.String</method-param>
            </method-params>
         </method>
         <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>
         <method>
            <ejb-name>Bank</ejb-name>
            <method-name>*</method-name>
         </method>
         <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <exclude-list>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>excludedMethod</method-name>
         </method>
      </exclude-list>
   </assembly-descriptor>
</ejb-jar>

2.2 Explanation

The below table explains each element of deployment descriptor based on ejb-jar_2_0.dtd.

Note: Occurrence of an element (column #) meaning:

  • 1 = Must use once.
  • + = Must use 0 or 1 time.
  • ? = Must use 1 or more.
  • * = Must use 0 or more.
Element#Description
ejb-jar1The ejb-jar element is the root element of the EJB deployment descriptor. It contains:

  • an optional description of the ejb-jar file
  • an optional display name
  • an optional small icon file name
  • an optional large icon file name
  • mandatory structural information about all included enterprise beans
  • a descriptor for container managed relationships, if any
  • an optional application-assembly descriptor
  • an optional name of an ejb-client-jar file for the ejb-jar.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
display-name?The display-name element contains a short name that is intended to be displayed by tools. The display name need not be unique.

Example:

<display-name>Employee Self Service</display-name>

small-icon?Specify the file name for a small (16 x 16) GIF or JPEG icon image used to represent the parent element in a GUI tool.

The file name is a relative path within the the application’s ear file.

Example:

<small-icon>employee-service-icon16x16.jpg</small-icon>

large-icon?Specify the file name for a large (32 x 32) GIF or JPEG icon image used to represent the parent element in a GUI tool.

The file name is a relative path within the the application’s ear file.

Example:

<large-icon>employee-service-icon32x32.jpg</large-icon>

enterprise-beans1The enterprise-beans element contains the declarations of one or more enterprise beans.
session|
entity |
message-driven
+The session element declares an session bean.
The entity element declares an entity bean.
The message-driven element declares a message-driven bean.
***** If <session> element is used *****

The session element declares an session bean. The declaration consists of:

  • an optional description
  • an optional display name
  • an optional small icon file name
  • an optional large icon file name
  • a name assigned to the enterprise bean in the deployment description
  • the names of the session bean’s remote home and remote interfaces, if any
  • the names of the session bean³s local home and local interfaces, if any
  • the session bean’s implementation class
  • the session bean’s state management type
  • the session bean’s transaction management type
  • an optional declaration of the bean’s environment entries
  • an optional declaration of the bean’s EJB references
  • an optional declaration of the bean’s local EJB references
  • an optional declaration of the security role references
  • an optional declaration of the security identity to be used for the execution of the bean’s methods
  • an optional declaration of the bean’s resource manager connection factory references
  • an optional declaration of the bean’s resource environment references.

The elements that are optional are “optional” in the sense that they are omitted when if lists represented by them are empty.

Either both the local-home and the local elements or both the home and the remote elements must be specified for the session bean.

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
display-name?The display-name element contains a short name that is intended to be displayed by tools. The display name need not be unique.

Example:

<display-name>Employee Self Service</display-name>

small-icon?Specify the file name for a small (16 x 16) GIF or JPEG icon image used to represent the parent element in a GUI tool.

The file name is a relative path within the the application’s ear file.

Example:

<small-icon>employee-service-icon16x16.jpg</small-icon>

large-icon?Specify the file name for a large (32 x 32) GIF or JPEG icon image used to represent the parent element in a GUI tool.

The file name is a relative path within the the application’s ear file.

Example:

<large-icon>employee-service-icon32x32.jpg</large-icon>

ejb-name1The ejb-name element specifies an enterprise bean’s name. This name is assigned by the ejb-jar file producer to name the enterprise bean in the ejb-jar file’s deployment descriptor. The name must be unique among the names of the enterprise beans in the same ejb-jar file.

There is no architected relationship between the ejb-name in the deployment descriptor and the JNDI name that the Deployer will assign to the enterprise bean’s home.

The name for an entity bean with cmp-version 2.x must conform to the lexical rules for an NMTOKEN. The name for an entity bean with cmp-version 2.x must not be a reserved literal in EJB QL.

Example:

<ejb-name>EmployeeService</ejb-name>

home?The home element contains the fully-qualified name of the enterprise bean’s home interface.

Example:

<home>com.aardvark.payroll.PayrollHome</home>

remote?The remote element contains the fully-qualified name of the enterprise bean’s remote interface.

Example:

<remote>com.wombat.empl.EmployeeService</remote>

local-home?The local-home element contains the fully-qualified name of the enterprise bean’s local home interface.
local?The local element contains the fully-qualified name of the enterprise bean’s local interface.
ejb-class1The ejb-class element contains the fully-qualified name of the enterprise bean’s class.

<ejb-class>com.wombat.empl.EmployeeServiceBean</ejb-class>

session-type1The session-type element describes whether the session bean is a stateful session or stateless session.

The session-type element must be one of the two following:

<session-type>Stateful</session-type>
<session-type>Stateless</session-type>

transaction-type1The transaction-type element specifies an enterprise bean’s transaction management type.

The transaction-type element must be one of the two following:

<transaction-type>Bean</transaction-type>
<transaction-type>Container</transaction-type>

env-entry*The env-entry element contains the declaration of an enterprise bean’s environment entry. The declaration consists of an optional description, the name of the environment entry, and an optional value. If a value is not specified, one must be supplied during deployment.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
env-entry-name1The env-entry-name element contains the name of an enterprise bean’s environment entry. The name is a JNDI name relative to the java:comp/env context. The name must be unique within an enterprise bean.

Example:

<env-entry-name>minAmount</env-entry-name>

env-entry-type1The env-entry-type element contains the fully-qualified Java type of the environment entry value that is expected by the enterprise bean’s code.

The following are the legal values of env-entry-type:

java.lang.Boolean
java.lang.Byte
java.lang.Character
java.lang.String
java.lang.Short
java.lang.Integer
java.lang.Long
java.lang.Float
java.lang.Double

Example:

<env-entry-type>java.lang.Boolean</env-entry-type>

env-entry-value?The env-entry-value element contains the value of an enterprise bean’s environment entry. The value must be a String that is valid for the constructor of the specified type that takes a single String parameter, or for java.lang.Character, a single character.

Example:

<env-entry-value>100.00</env-entry-value>

ejb-ref*The ejb-ref element is used for the declaration of a reference to an enterprise bean’s home. The declaration consists of:

  • an optional description
  • the EJB reference name used in the code of the enterprise bean that’s referencing the enterprise bean
  • the expected type of the referenced enterprise bean
  • the expected home and remote interfaces of the referenced enterprise bean
  • optional ejb-link information, used to specify the referenced enterprise bean
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-ref-name1The ejb-ref-name element contains the name of an EJB reference. The EJB reference is an entry in the enterprise bean’s environment and is relative to the java:comp/env context. The name must be unique within the enterprise bean.

It is recommended that name is prefixed with “ejb/”.

Example:

<ejb-ref-name>ejb/Payroll</ejb-ref-name>

ejb-ref-type1The ejb-ref-type element contains the expected type of the referenced enterprise bean.

The ejb-ref-type element must be one of the following:

<ejb-ref-type>Entity</ejb-ref-type> <ejb-ref-type>Session</ejb-ref-type>

home1The home element contains the fully-qualified name of the enterprise bean’s home interface.

Example:

<home>com.aardvark.payroll.PayrollHome</home>

remote1The remote element contains the fully-qualified name of the enterprise bean’s remote interface.

Example:

<remote>com.wombat.empl.EmployeeService</remote>

ejb-link?The ejb-link element is used in the ejb-ref or ejb-local-ref elements to specify that an EJB reference is linked to an enterprise bean.

The value of the ejb-link element must be the ejb-name of an enterprise bean in the same ejb-jar file or in another ejb-jar file in the same J2EE application unit.

Alternatively, the name in the ejb-link element may be composed of a path name specifying the ejb-jar containing the referenced enterprise bean with the ejb-name of the target bean appended and separated from the path name by “#”. The path name is relative to the ejb-jar file containing the enterprise bean that is referencing the enterprise bean. This allows multiple enterprise beans with the same ejb-name to be uniquely identified.

Examples:

<ejb-link>EmployeeRecord</ejb-link>
<ejb-link>../products/product.jar#ProductEJB</ejb-link>

ejb-local-ref*The ejb-local-ref element is used for the declaration of a reference to an enterprise bean’s local home. The declaration consists of:

  • an optional description
  • the EJB reference name used in the code of the enterprise bean that’s referencing the enterprise bean
  • the expected type of the referenced enterprise bean
  • the expected local home and local interfaces of the referenced enterprise bean
  • optional ejb-link information, used to specify the referenced enterprise bean
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-ref-name1The ejb-ref-name element contains the name of an EJB reference. The EJB reference is an entry in the enterprise bean’s environment and is relative to the java:comp/env context. The name must be unique within the enterprise bean.

It is recommended that name is prefixed with “ejb/”.

Example:

<ejb-ref-name>ejb/Payroll</ejb-ref-name>

ejb-ref-type1The ejb-ref-type element contains the expected type of the referenced enterprise bean.

The ejb-ref-type element must be one of the following:

<ejb-ref-type>Entity</ejb-ref-type> <ejb-ref-type>Session</ejb-ref-type>

local-home1The local-home element contains the fully-qualified name of the enterprise bean’s local home interface.
local1The local element contains the fully-qualified name of the enterprise bean’s local interface.
ejb-link?The ejb-link element is used in the ejb-ref or ejb-local-ref elements to specify that an EJB reference is linked to an enterprise bean.

The value of the ejb-link element must be the ejb-name of an enterprise bean in the same ejb-jar file or in another ejb-jar file in the same J2EE application unit.

Alternatively, the name in the ejb-link element may be composed of a path name specifying the ejb-jar containing the referenced enterprise bean with the ejb-name of the target bean appended and separated from the path name by “#”. The path name is relative to the ejb-jar file containing the enterprise bean that is referencing the enterprise bean. This allows multiple enterprise beans with the same ejb-name to be uniquely identified.

Examples:

<ejb-link>EmployeeRecord</ejb-link>
<ejb-link>../products/product.jar#ProductEJB</ejb-link>

security-role-ref*The security-role-ref element contains the declaration of a security role reference in the enterprise bean’s code. The declaration consists of an optional description, the security role name used in the code, and an optional link to a security role. If the security role is not specified, the Deployer must choose an appropriate security role.

The value of the role-name element must be the String used as the parameter to the EJBContext.isCallerInRole(String roleName) method or the HttpServletRequest.isUserInRole(String role) method.

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
role-name1The role-name element contains the name of a security role.

The name must conform to the lexical rules for an NMTOKEN.

role-link?The role-link element is a reference to a defined security role. The role-link element must contain the name of one of the security roles defined in the security-role elements.
security-identity?The security-identity element specifies whether the caller’s security identity is to be used for the execution of the methods of the enterprise bean or whether a specific run-as identity is to be used. It contains an optional description and a specification of the security identity to be used.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
use-caller-identity | run-as1The use-caller-identity element specifies that the caller’s security identity be used as the security identity for the execution of the enterprise bean’s methods. This element is empty.
description?Use the description element if the parent element is run-as

The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.

role-name1Use the role-name element if the parent element is run-as.

The role-name element contains the name of a security role. The name must conform to the lexical rules for an NMTOKEN.

resource-ref*The resource-ref element contains a declaration of an enterprise bean’s reference to an external resource. It consists of an optional description, the resource manager connection factory reference name, the indication of the resource manager connection factory type expected by the enterprise bean code, the type of authentication (Application or Container), and an optional specification of the shareability of connections obtained from the resource (Shareable or Unshareable).

Example:

<resource-ref>
<res-ref-name>jdbc/EmployeeAppDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
res-ref-name1The res-ref-name element specifies the name of a resource manager connection factory reference. The name is a JNDI name relative to the java:comp/env context. The name must be unique within an enterprise bean.
res-type1The res-type element specifies the type of the data source. The type is specified by the fully qualified Java language class or interface expected to be implemented by the data source.
res-auth1The res-auth element specifies whether the enterprise bean code signs on programmatically to the resource manager, or whether the Container will sign on to the resource manager on behalf of the enterprise bean. In the latter case, the Container uses information that is supplied by the Deployer.

The value of this element must be one of the two following:

<res-auth>Application</res-auth>
<res-auth>Container</res-auth>

res-sharing-scope?The res-sharing-scope element specifies whether connections obtained through the given resource manager connection factory reference can be shared. The value of this element, if specified, must be one of the two following:

<res-sharing-scope>Shareable</res-sharing-scope>
<res-sharing-scope>Unshareable</res-sharing-scope>

The default value is Shareable.

resource-env-ref*The resource-env-ref element contains a declaration of an enterprise bean’s reference to an administered object associated with a resource in the enterprise bean’s environment. It consists of an optional description, the resource environment reference name, and an indication of the resource environment reference type expected by the enterprise bean code.

Example:

<resource-env-ref>
<resource-env-ref-name>jms/StockQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
resource-env-ref-name1The resource-env-ref-name element specifies the name of a resource environment reference; its value is the environment entry name used in the enterprise bean code. The name is a JNDI name relative to the java:comp/env context and must be unique within an enterprise bean.
resource-env-ref-type1The resource-env-ref-type element specifies the type of a resource environment reference. It is the fully qualified name of a Java language class or interface.
***** If <entity> element is used *****

The entity element declares an entity bean. The declaration consists of:

  • an optional description
  • an optional display name
  • an optional small icon file name
  • an optional large icon file name
  • a unique name assigned to the enterprise bean in the deployment descriptor
  • the names of the entity bean’s remote home and remote interfaces, if any
  • the names of the entity bean’s local home and local interfaces, if any
  • the entity bean’s implementation class
  • the entity bean’s persistence management type
  • the entity bean’s primary key class name
  • an indication of the entity bean’s reentrancy
  • an optional specification of the entity bean’s cmp-version
  • an optional specification of the entity bean’s abstract schema name
  • an optional list of container-managed fields
  • an optional specification of the primary key field
  • an optional declaration of the bean’s environment entries
  • an optional declaration of the bean’s EJB references
  • an optional declaration of the bean’s local EJB references
  • an optional declaration of the security role references
  • an optional declaration of the security identity to be used for the execution of the bean’s methods
  • an optional declaration of the bean’s resource manager connection factory references
  • an optional declaration of the bean’s resource environment references
  • an optional set of query declarations for finder and select methods for an entity bean with cmp-version 2.x.

The optional abstract-schema-name element must be specified for an entity bean with container-managed persistence and cmp-version 2.x.

The optional primkey-field may be present in the descriptor if the entity’s persistence-type is Container.

The optional cmp-version element may be present in the descriptor if the entity’s persistence-type is Container. If the persistence-type is Container and the cmp-version element is not specified, its value defaults to 2.x.

The optional home and remote elements must be specified if the entity bean cmp-version is 1.x.

The optional home and remote elements must be specified if the entity bean has a remote home and remote interface.

The optional local-home and local elements must be specified if the entity bean has a local home and local interface.

Either both the local-home and the local elements or both the home and the remote elements must be specified.

The optional query elements must be present if the persistence-type is Container and the cmp-version is 2.x and query methods other than findByPrimaryKey have been defined for the entity bean.

The other elements that are optional are “optional” in the sense that they are omitted if the lists represented by them are empty.

At least one cmp-field element must be present in the descriptor if the entity’s persistence-type is Container and the cmp-version is 1.x, and none must not be present if the entity’s persistence-type is Bean.

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
display-name?The display-name element contains a short name that is intended to be displayed by tools. The display name need not be unique.

Example:

<display-name>Employee Self Service</display-name>

small-icon?Specify the file name for a small (16 x 16) GIF or JPEG icon image used to represent the parent element in a GUI tool.

The file name is a relative path within the the application’s ear file.

Example:

<small-icon>employee-service-icon16x16.jpg</small-icon>

large-icon?Specify the file name for a large (32 x 32) GIF or JPEG icon image used to represent the parent element in a GUI tool.

The file name is a relative path within the the application’s ear file.

Example:

<large-icon>employee-service-icon32x32.jpg</large-icon>

ejb-name1The ejb-name element specifies an enterprise bean’s name. This name is assigned by the ejb-jar file producer to name the enterprise bean in the ejb-jar file’s deployment descriptor. The name must be unique among the names of the enterprise beans in the same ejb-jar file.

There is no architected relationship between the ejb-name in the deployment descriptor and the JNDI name that the Deployer will assign to the enterprise bean’s home.

The name for an entity bean with cmp-version 2.x must conform to the lexical rules for an NMTOKEN. The name for an entity bean with cmp-version 2.x must not be a reserved literal in EJB QL.

Example:

<ejb-name>EmployeeService</ejb-name>

home?The home element contains the fully-qualified name of the enterprise bean’s home interface.

Example:

<home>com.aardvark.payroll.PayrollHome</home>

remote?The remote element contains the fully-qualified name of the enterprise bean’s remote interface.

Example:

<remote>com.wombat.empl.EmployeeService</remote>

local-home?The local-home element contains the fully-qualified name of the enterprise bean’s local home interface.
local?The local element contains the fully-qualified name of the enterprise bean’s local interface.
ejb-class1The ejb-class element contains the fully-qualified name of the enterprise bean’s class.

<ejb-class>com.wombat.empl.EmployeeServiceBean</ejb-class>

persistence-type1The persistence-type element specifies an entity bean’s persistence management type.

The persistence-type element must be one of the two following:

<persistence-type>Bean</persistence-type>
<persistence-type>Container</persistence-type>

prim-key-class1The prim-key-class element contains the fully-qualified name of an entity bean’s primary key class.

If the definition of the primary key class is deferred to deployment time, the prim-key-class element should specify java.lang.Object.

Examples:

<prim-key-class>java.lang.String</prim-key-class>
<prim-key-class>com.wombat.empl.EmployeeID</prim-key-class>
<prim-key-class>java.lang.Object</prim-key-class>

reentrant1The reentrant element specifies whether an entity bean is reentrant or not.

The reentrant element must be one of the two following:

<reentrant>True</reentrant>
<reentrant>False</reentrant>

cmp-version?The cmp-version element specifies the version of an entity bean with container-managed persistence.

The cmp-version element must be one of the two following:

<cmp-version>1.x</cmp-version>
<cmp-version>2.x</cmp-version>

The default value of the cmp-version element is 2.x.

abstract-schema-name?The abstract-schema-name element specifies the name of the abstract schema type of an entity bean with cmp-version 2.x. It is used in EJB QL queries.

For example, the abstract-schema-name for an entity bean whose local interface is com.acme.commerce.Order might be Order.

cmp-field*The cmp-field element describes a container-managed field. The field element includes an optional description of the field, and the name of the field.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
field-name1The field-name element specifies the name of a container managed field.

The name of the cmp-field of an entity bean with cmp-version 2.x must begin with a lowercase letter. This field is accessed by methods whose names consists of the name of the field specified by field-name in which the first letter is uppercased, prefixed by “get” or “set”.

The name of the cmp-field of an entity bean with cmp-version 1.x must denote a public field of the enterprise bean class or one of its superclasses.

Example:

<field-name>firstName</field-Name>

primkey-field?The primkey-field element is used to specify the name of the primary key field for an entity with container-managed persistence.

The primkey-field must be one of the fields declared in the cmp-field element, and the type of the field must be the same as the primary key type.

The primkey-field element is not used if the primary key maps to multiple container-managed fields (i.e. the key is a compound key). In this case, the fields of the primary key class must be public, and their names must correspond to the field names of the entity bean class that comprise the key.

Example:

<primkey-field>EmployeeId</primkey-field>

env-entry*The env-entry element contains the declaration of an enterprise bean’s environment entry. The declaration consists of an optional description, the name of the environment entry, and an optional value. If a value is not specified, one must be supplied during deployment.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
env-entry-name1The env-entry-name element contains the name of an enterprise bean’s environment entry. The name is a JNDI name relative to the java:comp/env context. The name must be unique within an enterprise bean.

Example:

<env-entry-name>minAmount</env-entry-name>

env-entry-type1The env-entry-type element contains the fully-qualified Java type of the environment entry value that is expected by the enterprise bean’s code.

The following are the legal values of env-entry-type:

java.lang.Boolean
java.lang.Byte
java.lang.Character
java.lang.String
java.lang.Short
java.lang.Integer
java.lang.Long
java.lang.Float
java.lang.Double

Example:

<env-entry-type>java.lang.Boolean</env-entry-type>

env-entry-value?The env-entry-value element contains the value of an enterprise bean’s environment entry. The value must be a String that is valid for the constructor of the specified type that takes a single String parameter, or for java.lang.Character, a single character.

Example:

<env-entry-value>100.00</env-entry-value>

ejb-ref*The ejb-ref element is used for the declaration of a reference to an enterprise bean’s home. The declaration consists of:

  • an optional description
  • the EJB reference name used in the code of the enterprise bean that’s referencing the enterprise bean
  • the expected type of the referenced enterprise bean
  • the expected home and remote interfaces of the referenced enterprise bean
  • optional ejb-link information, used to specify the referenced enterprise bean
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-ref-name1The ejb-ref-name element contains the name of an EJB reference. The EJB reference is an entry in the enterprise bean’s environment and is relative to the java:comp/env context. The name must be unique within the enterprise bean.

It is recommended that name is prefixed with “ejb/”.

Example:

<ejb-ref-name>ejb/Payroll</ejb-ref-name>

ejb-ref-type1The ejb-ref-type element contains the expected type of the referenced enterprise bean.

The ejb-ref-type element must be one of the following:

<ejb-ref-type>Entity</ejb-ref-type> <ejb-ref-type>Session</ejb-ref-type>

home1The home element contains the fully-qualified name of the enterprise bean’s home interface.

Example:

<home>com.aardvark.payroll.PayrollHome</home>

remote1The remote element contains the fully-qualified name of the enterprise bean’s remote interface.

Example:

<remote>com.wombat.empl.EmployeeService</remote>

ejb-link?The ejb-link element is used in the ejb-ref or ejb-local-ref elements to specify that an EJB reference is linked to an enterprise bean.

The value of the ejb-link element must be the ejb-name of an enterprise bean in the same ejb-jar file or in another ejb-jar file in the same J2EE application unit.

Alternatively, the name in the ejb-link element may be composed of a path name specifying the ejb-jar containing the referenced enterprise bean with the ejb-name of the target bean appended and separated from the path name by “#”. The path name is relative to the ejb-jar file containing the enterprise bean that is referencing the enterprise bean. This allows multiple enterprise beans with the same ejb-name to be uniquely identified.

Examples:

<ejb-link>EmployeeRecord</ejb-link>
<ejb-link>../products/product.jar#ProductEJB</ejb-link>

ejb-local-ref*The ejb-local-ref element is used for the declaration of a reference to an enterprise bean’s local home. The declaration consists of:

  • an optional description
  • the EJB reference name used in the code of the enterprise bean that’s referencing the enterprise bean
  • the expected type of the referenced enterprise bean
  • the expected local home and local interfaces of the referenced enterprise bean
  • optional ejb-link information, used to specify the referenced enterprise bean
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-ref-name1The ejb-ref-name element contains the name of an EJB reference. The EJB reference is an entry in the enterprise bean’s environment and is relative to the java:comp/env context. The name must be unique within the enterprise bean.

It is recommended that name is prefixed with “ejb/”.

Example:

<ejb-ref-name>ejb/Payroll</ejb-ref-name>

ejb-ref-type1The ejb-ref-type element contains the expected type of the referenced enterprise bean.

The ejb-ref-type element must be one of the following:

<ejb-ref-type>Entity</ejb-ref-type> <ejb-ref-type>Session</ejb-ref-type>

local-home1The local-home element contains the fully-qualified name of the enterprise bean’s local home interface.
local1The local element contains the fully-qualified name of the enterprise bean’s local interface.
ejb-link?The ejb-link element is used in the ejb-ref or ejb-local-ref elements to specify that an EJB reference is linked to an enterprise bean.

The value of the ejb-link element must be the ejb-name of an enterprise bean in the same ejb-jar file or in another ejb-jar file in the same J2EE application unit.

Alternatively, the name in the ejb-link element may be composed of a path name specifying the ejb-jar containing the referenced enterprise bean with the ejb-name of the target bean appended and separated from the path name by “#”. The path name is relative to the ejb-jar file containing the enterprise bean that is referencing the enterprise bean. This allows multiple enterprise beans with the same ejb-name to be uniquely identified.

Examples:

<ejb-link>EmployeeRecord</ejb-link>
<ejb-link>../products/product.jar#ProductEJB</ejb-link>

security-role-ref*The security-role-ref element contains the declaration of a security role reference in the enterprise bean’s code. The declaration consists of an optional description, the security role name used in the code, and an optional link to a security role. If the security role is not specified, the Deployer must choose an appropriate security role.

The value of the role-name element must be the String used as the parameter to the EJBContext.isCallerInRole(String roleName) method or the HttpServletRequest.isUserInRole(String role) method.

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
role-name1The role-name element contains the name of a security role.

The name must conform to the lexical rules for an NMTOKEN.

role-link?The role-link element is a reference to a defined security role. The role-link element must contain the name of one of the security roles defined in the security-role elements.
security-identity?The security-identity element specifies whether the caller’s security identity is to be used for the execution of the methods of the enterprise bean or whether a specific run-as identity is to be used. It contains an optional description and a specification of the security identity to be used.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
use-caller-identity | run-as1The use-caller-identity element specifies that the caller’s security identity be used as the security identity for the execution of the enterprise bean’s methods. This element is empty.
description?Use the description element if the parent element is run-as

The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.

role-name1Use the role-name element if the parent element is run-as.

The role-name element contains the name of a security role. The name must conform to the lexical rules for an NMTOKEN.

resource-ref*The resource-ref element contains a declaration of an enterprise bean’s reference to an external resource. It consists of an optional description, the resource manager connection factory reference name, the indication of the resource manager connection factory type expected by the enterprise bean code, the type of authentication (Application or Container), and an optional specification of the shareability of connections obtained from the resource (Shareable or Unshareable).

Example:

<resource-ref>
<res-ref-name>jdbc/EmployeeAppDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
res-ref-name1The res-ref-name element specifies the name of a resource manager connection factory reference. The name is a JNDI name relative to the java:comp/env context. The name must be unique within an enterprise bean.
res-type1The res-type element specifies the type of the data source. The type is specified by the fully qualified Java language class or interface expected to be implemented by the data source.
res-auth1The res-auth element specifies whether the enterprise bean code signs on programmatically to the resource manager, or whether the Container will sign on to the resource manager on behalf of the enterprise bean. In the latter case, the Container uses information that is supplied by the Deployer.

The value of this element must be one of the two following:

<res-auth>Application</res-auth>
<res-auth>Container</res-auth>

res-sharing-scope?The res-sharing-scope element specifies whether connections obtained through the given resource manager connection factory reference can be shared. The value of this element, if specified, must be one of the two following:

<res-sharing-scope>Shareable</res-sharing-scope>
<res-sharing-scope>Unshareable</res-sharing-scope>

The default value is Shareable.

resource-env-ref*The resource-env-ref element contains a declaration of an enterprise bean’s reference to an administered object associated with a resource in the enterprise bean’s environment. It consists of an optional description, the resource environment reference name, and an indication of the resource environment reference type expected by the enterprise bean code.

Example:

<resource-env-ref>
<resource-env-ref-name>jms/StockQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
resource-env-ref-name1The resource-env-ref-name element specifies the name of a resource environment reference; its value is the environment entry name used in the enterprise bean code. The name is a JNDI name relative to the java:comp/env context and must be unique within an enterprise bean.
resource-env-ref-type1The resource-env-ref-type element specifies the type of a resource environment reference. It is the fully qualified name of a Java language class or interface.
query*The query element is used to specify a finder or select query. It contains:

  • an optional description of the query
  • the specification of the finder or select method it is used by
  • an optional specification of the result type mapping, if the query is for a select method and entity objects are returned.
  • the EJB QL query string that defines the query.

Queries that are expressible in EJB QL must use the ejb-ql element to specify the query. If a query is not expressible in EJB QL, the description element should be used to describe the semantics of the query and the ejb-ql element should be empty.

The result-type-mapping is an optional element. It can only be present if the query-method specifies a select method that returns entity objects. The default value for the result-type-mapping element is “Local”.

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
query-method1The query-method element is used to specify the method for a finder or select query.

The method-name element specifies the name of a finder or select method in the entity bean’s implementation class.

Each method-param must be defined for a query-method using the method-params element.

Example:

<query>
<description>Method finds large orders</description>
<query-method>
<method-name>findLargeOrders</method-name>
<method-params></method-params>
</query-method>
<ejb-ql>SELECT OBJECT(o) FROM Order o WHERE o.amount > 1000</ejb-ql>
</query>

method-name1The method-name element contains a name of an enterprise bean method or the asterisk (*) character. The asterisk is used when the element denotes all the methods of an enterprise bean’s component and home interfaces.
method-params1The method-param element contains the fully-qualified Java type name of a method parameter.
method-param*The method-param element contains the fully-qualified Java type name of a method parameter.
result-type-mapping?The result-type-mapping element is used in the query element to specify whether an abstract schema type returned by a query for a select method is to be mapped to an EJBLocalObject or EJBObject type.

The result-type-mapping element must be one of the following:

<result-type-mapping>Local</result-type-mapping>
<result-type-mapping>Remote</result-type-mapping>

ejb-ql1The ejb-ql element contains the EJB QL query string that defines a finder or select query. This element is defined within the scope of a query element whose contents specify the finder or the select method that uses the query. The content must be a valid EJB QL query string for the entity bean for which the query is specified.

The ejb-ql element must be specified for all queries that are expressible in EJB QL.

Example:

<query>
<query-method>
<method-name>ejbSelectPendingLineitems</method-name>
<method-params/>
</query-method>
<ejb-ql>SELECT OBJECT(l) FROM LineItems l WHERE l.shipped <> TRUE
</ejb-ql>
</query>

***** If <message-driven> element is used *****

The message-driven element declares a message-driven bean. The declaration consists of:

  • an optional description
  • an optional display name
  • an optional small icon file name
  • an optional large icon file name
  • a name assigned to the enterprise bean in the deployment descriptor
  • the message-driven bean’s implementation class
  • the message-driven bean’s transaction management type
  • an optional declaration of the message-driven bean’s message selector
  • an optional declaration of the acknowledgment mode for the message-driven bean if bean-managed transaction demarcation is used
  • an optional declaration of the intended destination type of the message-driven bean
  • an optional declaration of the bean’s environment entries
  • an optional declaration of the bean’s EJB references
  • an optional declaration of the bean’s local EJB references
  • an optional declaration of the security identity to be used for the execution of the bean’s methods
  • an optional declaration of the bean’s resource manager connection factory references
  • an optional declaration of the bean’s resource environment references.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
display-name?The display-name element contains a short name that is intended to be displayed by tools. The display name need not be unique.

Example:

<display-name>Employee Self Service</display-name>

small-icon?Specify the file name for a small (16 x 16) GIF or JPEG icon image used to represent the parent element in a GUI tool.

The file name is a relative path within the the application’s ear file.

Example:

<small-icon>employee-service-icon16x16.jpg</small-icon>

large-icon?Specify the file name for a large (32 x 32) GIF or JPEG icon image used to represent the parent element in a GUI tool.

The file name is a relative path within the the application’s ear file.

Example:

<large-icon>employee-service-icon32x32.jpg</large-icon>

ejb-name1The ejb-name element specifies an enterprise bean’s name. This name is assigned by the ejb-jar file producer to name the enterprise bean in the ejb-jar file’s deployment descriptor. The name must be unique among the names of the enterprise beans in the same ejb-jar file.

There is no architected relationship between the ejb-name in the deployment descriptor and the JNDI name that the Deployer will assign to the enterprise bean’s home.

The name for an entity bean with cmp-version 2.x must conform to the lexical rules for an NMTOKEN. The name for an entity bean with cmp-version 2.x must not be a reserved literal in EJB QL.

Example:

<ejb-name>EmployeeService</ejb-name>

ejb-class1The ejb-class element contains the fully-qualified name of the enterprise bean’s class.

<ejb-class>com.wombat.empl.EmployeeServiceBean</ejb-class>

transaction-type1The transaction-type element specifies an enterprise bean’s transaction management type.

The transaction-type element must be one of the two following:

<transaction-type>Bean</transaction-type>
<transaction-type>Container</transaction-type>

message-selector?The message-selector element is used to specify the JMS message selector to be used in determining which messages a message-driven bean is to receive.

Example:

<message-selector>JMSType = ‘car’ AND color = ‘blue’ AND weight > 2500 </message-selector>

acknowledge-mode?The acknowledge-mode element specifies whether JMS AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE message acknowledgment semantics should be used for the onMessage message of a message-driven bean that uses bean managed transaction demarcation.

The acknowledge-mode element must be one of the two following:

<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<acknowledge-mode>Dups-ok-acknowledge</acknowledgemode>

message-driven-destination?The message-driven-destination element provides advice to the Deployer as to whether a message-driven bean is intended for a Queue or a Topic. The declaration consists of: the type of the message-driven bean’s intended destination and an optional declaration of whether a durable or non-durable subscription should be used if the destination-type is javax.jms.Topic.
destination-type1The destination-type element specifies the type of the JMS destination. The type is specified by the Java interface expected to be implemented by the destination.

The destination-type element must be one of the two following:

<destination-type>javax.jms.Queue</destination-type>
<destination-type>javax.jms.Topic</destination-type>

subscription-durability?The subscription-durability element specifies whether a JMS topic subscription is intended to be durable or nondurable.

The subscription-durability element must be one of the two following:

<subscription-durability>Durable</subscription-durability>
<subscription-durability>NonDurable</subscription-durability>

env-entry*The env-entry element contains the declaration of an enterprise bean’s environment entry. The declaration consists of an optional description, the name of the environment entry, and an optional value. If a value is not specified, one must be supplied during deployment.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
env-entry-name1The env-entry-name element contains the name of an enterprise bean’s environment entry. The name is a JNDI name relative to the java:comp/env context. The name must be unique within an enterprise bean.

Example:

<env-entry-name>minAmount</env-entry-name>

env-entry-type1The env-entry-type element contains the fully-qualified Java type of the environment entry value that is expected by the enterprise bean’s code.

The following are the legal values of env-entry-type:

java.lang.Boolean
java.lang.Byte
java.lang.Character
java.lang.String
java.lang.Short
java.lang.Integer
java.lang.Long
java.lang.Float
java.lang.Double

Example:

<env-entry-type>java.lang.Boolean</env-entry-type>

env-entry-value?The env-entry-value element contains the value of an enterprise bean’s environment entry. The value must be a String that is valid for the constructor of the specified type that takes a single String parameter, or for java.lang.Character, a single character.

Example:

<env-entry-value>100.00</env-entry-value>

ejb-ref*The ejb-ref element is used for the declaration of a reference to an enterprise bean’s home. The declaration consists of:

  • an optional description
  • the EJB reference name used in the code of the enterprise bean that’s referencing the enterprise bean
  • the expected type of the referenced enterprise bean
  • the expected home and remote interfaces of the referenced enterprise bean
  • optional ejb-link information, used to specify the referenced enterprise bean
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-ref-name1The ejb-ref-name element contains the name of an EJB reference. The EJB reference is an entry in the enterprise bean’s environment and is relative to the java:comp/env context. The name must be unique within the enterprise bean.

It is recommended that name is prefixed with “ejb/”.

Example:

<ejb-ref-name>ejb/Payroll</ejb-ref-name>

ejb-ref-type1The ejb-ref-type element contains the expected type of the referenced enterprise bean.

The ejb-ref-type element must be one of the following:

<ejb-ref-type>Entity</ejb-ref-type> <ejb-ref-type>Session</ejb-ref-type>

home1The home element contains the fully-qualified name of the enterprise bean’s home interface.

Example:

<home>com.aardvark.payroll.PayrollHome</home>

remote1The remote element contains the fully-qualified name of the enterprise bean’s remote interface.

Example:

<remote>com.wombat.empl.EmployeeService</remote>

ejb-link?The ejb-link element is used in the ejb-ref or ejb-local-ref elements to specify that an EJB reference is linked to an enterprise bean.

The value of the ejb-link element must be the ejb-name of an enterprise bean in the same ejb-jar file or in another ejb-jar file in the same J2EE application unit.

Alternatively, the name in the ejb-link element may be composed of a path name specifying the ejb-jar containing the referenced enterprise bean with the ejb-name of the target bean appended and separated from the path name by “#”. The path name is relative to the ejb-jar file containing the enterprise bean that is referencing the enterprise bean. This allows multiple enterprise beans with the same ejb-name to be uniquely identified.

Examples:

<ejb-link>EmployeeRecord</ejb-link>
<ejb-link>../products/product.jar#ProductEJB</ejb-link>

ejb-local-ref*The ejb-local-ref element is used for the declaration of a reference to an enterprise bean’s local home. The declaration consists of:

  • an optional description
  • the EJB reference name used in the code of the enterprise bean that’s referencing the enterprise bean
  • the expected type of the referenced enterprise bean
  • the expected local home and local interfaces of the referenced enterprise bean
  • optional ejb-link information, used to specify the referenced enterprise bean
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-ref-name1The ejb-ref-name element contains the name of an EJB reference. The EJB reference is an entry in the enterprise bean’s environment and is relative to the java:comp/env context. The name must be unique within the enterprise bean.

It is recommended that name is prefixed with “ejb/”.

Example:

<ejb-ref-name>ejb/Payroll</ejb-ref-name>

ejb-ref-type1The ejb-ref-type element contains the expected type of the referenced enterprise bean.

The ejb-ref-type element must be one of the following:

<ejb-ref-type>Entity</ejb-ref-type> <ejb-ref-type>Session</ejb-ref-type>

local-home1The local-home element contains the fully-qualified name of the enterprise bean’s local home interface.
local1The local element contains the fully-qualified name of the enterprise bean’s local interface.
ejb-link?The ejb-link element is used in the ejb-ref or ejb-local-ref elements to specify that an EJB reference is linked to an enterprise bean.

The value of the ejb-link element must be the ejb-name of an enterprise bean in the same ejb-jar file or in another ejb-jar file in the same J2EE application unit.

Alternatively, the name in the ejb-link element may be composed of a path name specifying the ejb-jar containing the referenced enterprise bean with the ejb-name of the target bean appended and separated from the path name by “#”. The path name is relative to the ejb-jar file containing the enterprise bean that is referencing the enterprise bean. This allows multiple enterprise beans with the same ejb-name to be uniquely identified.

Examples:

<ejb-link>EmployeeRecord</ejb-link>
<ejb-link>../products/product.jar#ProductEJB</ejb-link>

security-identity?The security-identity element specifies whether the caller’s security identity is to be used for the execution of the methods of the enterprise bean or whether a specific run-as identity is to be used. It contains an optional description and a specification of the security identity to be used.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
use-caller-identity | run-as1The use-caller-identity element specifies that the caller’s security identity be used as the security identity for the execution of the enterprise bean’s methods. This element is empty.
description?Use the description element if the parent element is run-as

The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.

role-name1Use the role-name element if the parent element is run-as.

The role-name element contains the name of a security role. The name must conform to the lexical rules for an NMTOKEN.

resource-ref*The resource-ref element contains a declaration of an enterprise bean’s reference to an external resource. It consists of an optional description, the resource manager connection factory reference name, the indication of the resource manager connection factory type expected by the enterprise bean code, the type of authentication (Application or Container), and an optional specification of the shareability of connections obtained from the resource (Shareable or Unshareable).

Example:

<resource-ref>
<res-ref-name>jdbc/EmployeeAppDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
res-ref-name1The res-ref-name element specifies the name of a resource manager connection factory reference. The name is a JNDI name relative to the java:comp/env context. The name must be unique within an enterprise bean.
res-type1The res-type element specifies the type of the data source. The type is specified by the fully qualified Java language class or interface expected to be implemented by the data source.
res-auth1The res-auth element specifies whether the enterprise bean code signs on programmatically to the resource manager, or whether the Container will sign on to the resource manager on behalf of the enterprise bean. In the latter case, the Container uses information that is supplied by the Deployer.

The value of this element must be one of the two following:

<res-auth>Application</res-auth>
<res-auth>Container</res-auth>

res-sharing-scope?The res-sharing-scope element specifies whether connections obtained through the given resource manager connection factory reference can be shared. The value of this element, if specified, must be one of the two following:

<res-sharing-scope>Shareable</res-sharing-scope>
<res-sharing-scope>Unshareable</res-sharing-scope>

The default value is Shareable.

resource-env-ref*The resource-env-ref element contains a declaration of an enterprise bean’s reference to an administered object associated with a resource in the enterprise bean’s environment. It consists of an optional description, the resource environment reference name, and an indication of the resource environment reference type expected by the enterprise bean code.

Example:

<resource-env-ref>
<resource-env-ref-name>jms/StockQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
resource-env-ref-name1The resource-env-ref-name element specifies the name of a resource environment reference; its value is the environment entry name used in the enterprise bean code. The name is a JNDI name relative to the java:comp/env context and must be unique within an enterprise bean.
resource-env-ref-type1The resource-env-ref-type element specifies the type of a resource environment reference. It is the fully qualified name of a Java language class or interface.
***** END SESSION, ENTITY OR MESSAGE-DRIVEN ELEMENT *****

//
relationships?The relationships element describes the relationships in which entity beans with container-managed persistence participate. The relationships element contains an optional description; and a list of ejb-relation elements, which specify the container managed relationships.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-relation+The ejb-relation element describes a relationship between two entity beans with container-managed persistence. An ejb-relation element contains a description; an optional ejb-relation-name element; and exactly two relationship role declarations, defined by the ejb-relationship-role elements. The name of the relationship, if specified, is unique within the ejb-jar file.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-relation-name?The ejb-relation-name element provides a unique name for a relationship.
ejb-relationship-role1The ejb-relationship-role element describes a role within a relationship. There are two roles in each relationship.

The ejb-relationship-role element contains an optional description; an optional name for the relationship role; a specification of the multiplicity of the role; an optional specification of cascade-delete functionality for the role; the role source; and a declaration of the cmr-field, if any, by means of which the other side of the relationship is accessed from the perspective of the role source.

The multiplicity and role-source element are mandatory.

The relationship-role-source element designates an entity bean by means of an ejb-name element. For bidirectional relationships, both roles of a relationship must declare a relationship-role-source element that specifies a cmr-field in terms of which the relationship is accessed. The lack of a cmr-field element in an ejb-relationship-role specifies that the relationship is unidirectional in navigability and the entity bean that participates in the relationship is “not aware” of the relationship.

Example:

<ejb-relation>
<ejb-relation-name>Product-LineItem</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>
product-has-lineitems
</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>ProductEJB</ejb-name>
</relationship-role-source>
</ejb-relationship-role>

ejb-relationship-role1Same as above.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-relationship-role-name?The ejb-relationship-role-name element defines a name for a role that is unique within an ejb-relation. Different relationships can use the same name for a role.
multiplicity1The multiplicity element describes the multiplicity of the role that participates in a relation.

The multiplicity element must be one of the two following:

<multiplicity>One</multiplicity>
<multiplicity>Many</multiplicity>

cascade-delete?This empty element specifies that, within a particular relationship, the lifetime of one or more entity beans is dependent upon the lifetime of another entity bean. The cascade-delete element can only be specified for an ejb-relationship-role element contained in an ejb-relation element in which the other ejb-relationship-role element specifies a multiplicity of One.
relationship-role-source1The ejb-relationship-role-name element defines a name for a role that is unique within an ejb-relation. Different relationships can use the same name for a role.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-name1The ejb-name element specifies an enterprise bean’s name. This name is assigned by the ejb-jar file producer to name the enterprise bean in the ejb-jar file’s deployment descriptor. The name must be unique among the names of the enterprise beans in the same ejb-jar file.

There is no architected relationship between the ejb-name in the deployment descriptor and the JNDI name that the Deployer will assign to the enterprise bean’s home.

The name for an entity bean with cmp-version 2.x must conform to the lexical rules for an NMTOKEN. The name for an entity bean with cmp-version 2.x must not be a reserved literal in EJB QL.

Example:

<ejb-name>EmployeeService</ejb-name>

cmr-field?The cmr-field element describes the bean provider’s view of a relationship. It consists of an optional description, and the name and the class type of a field in the source of a role of a relationship. The cmr-field-name element corresponds to the name used for the get and set accessor methods for the relationship. The cmr-field-type element is used only for collection-valued cmr-fields. It specifies the type of the collection that is used.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
cmr-field-name1The cmr-field-name element specifies the name of a logical relationship field in the entity bean class. The name of the cmr-field must begin with a lowercase letter. This field is accessed by methods whose names consist of the name of the field specified by cmr-field-name in which the first letter is uppercased, prefixed by “get” or “set”.
cmr-field-type?The cmr-field-type element specifies the class of a collection-valued logical relationship field in the entity bean class. The value of the cmr-field-type element must be either: java.util.Collection or java.util.Set.
assembly-descriptor?The assembly-descriptor element contains application-assembly information.

The application-assembly information consists of the following parts: the definition of security roles, the definition of method permissions, the definition of transaction attributes for enterprise beans with container-managed transaction demarcation and a list of methods to be excluded from being invoked.

All the parts are optional in the sense that they are omitted if the lists represented by them are empty.

Providing an assembly-descriptor in the deployment descriptor is optional for the ejb-jar file producer.

security-role*The security-role element contains the definition of a security role. The definition consists of an optional description of the security role, and the security role name.

Example:

<security-role>
<description>
This role includes all employees who are authorized
to access the employee service application.
</description>
<role-name>employee</role-name>
</security-role>

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
role-name1The role-name element contains the name of a security role.

The name must conform to the lexical rules for an NMTOKEN.

method-permission*The method-permission element specifies that one or more security roles are allowed to invoke one or more enterprise bean methods. The method-permission element consists of an optional description, a list of security role names or an indicator to state that the method is unchecked for authorization, and a list of method elements.

The security roles used in the method-permission element must be defined in the security-role elements of the deployment descriptor, and the methods must be methods defined in the enterprise bean’s component and/or home interfaces.

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
role-name |
unchecked
+
1
The role-name element contains the name of a security role. The name must conform to the lexical rules for an NMTOKEN.

The unchecked element specifies that a method is not checked for authorization by the container prior to invocation of the method.

method+The method element is used to denote a method of an enterprise bean’s home or component interface, or, in the case of a message-driven bean, the bean’s onMessage method, or a set of methods. The ejb-name element must be the name of one of the enterprise beans declared in the deployment descriptor; the optional method-intf element allows to distinguish between a method with the same signature that is multiply defined across in both the home and component interfaces; the method-name element specifies the method name; and the optional method-params elements identify a single method among multiple methods with an overloaded method name.

There are three possible styles of the method element syntax:

1.
<method>
<ejb-name>EJBNAME</ejb-name>
<method-name>*</method-name>
</method>

This style is used to refer to all the methods of the specified enterprise bean’s home and component interfaces.

2.
<method>
<ejb-name>EJBNAME</ejb-name>
<method-name>METHOD</method-name>
</method>>

This style is used to refer to the specified method of the specified enterprise bean. If there are multiple methods with the same overloaded name, the element of this style refers to all the methods with the overloaded name.

3.
<method>
<ejb-name>EJBNAME</ejb-name>
<method-name>METHOD</method-name>
<method-params>
<method-param>PARAM-1</method-param>
<method-param>PARAM-2</method-param>

<method-param>PARAM-n</method-param>
</method-params>
<method>

This style is used to refer to a single method within a set of methods with an overloaded name. PARAM-1 through PARAM-n are the fully-qualified Java types of the method’s input parameters (if the method has no input arguments, the method-params element contains no method-param elements). Arrays are specified by the array element’s type, followed by one or more pair of square brackets (e.g. int[ ][ ]). If there are multiple methods with the same overloaded name, this style refers to all of the overloaded methods.

Examples:

Style 1: The following method element refers to all the methods of the EmployeeService bean’s home and component interfaces:

<method>
<ejb-name>EmployeeService</ejb-name>
<method-name>*</method-name>
</method>

Style 2: The following method element refers to all the create methods of the EmployeeService bean’s home interface(s).

<method>
<ejb-name>EmployeeService</ejb-name>
<method-name>create</method-name>
</method>

Style 3: The following method element refers to the
create(String firstName, String LastName) method of the
EmployeeService bean’s home interface(s).

<method>
<ejb-name>EmployeeService</ejb-name>
<method-name>create</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>

The following example illustrates a Style 3 element with more complex parameter types. The method foobar(char s, int i, int[ ] iar, mypackage.MyClass mycl, mypackage.MyClass[ ][ ] myclaar) would be specified as:

<method>
<ejb-name>EmployeeService</ejb-name>
<method-name>foobar</method-name>
<method-params>
<method-param>char</method-param>
<method-param>int</method-param>
<method-param>int[ ]</method-param>
<method-param>mypackage.MyClass</method-param>
<method-param>mypackage.MyClass[ ][ ]</method-param>
</method-params>
</method>

The optional method-intf element can be used when it becomes necessary to differentiate between a method that is multiply defined across the enterprise bean’s home and component interfaces with the same name and signature.

For example, the method element

<method>
<ejb-name>EmployeeService</ejb-name>
<method-intf>Remote</method-intf>
<method-name>create</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>

can be used to differentiate the create(String, String) method defined in the remote interface from the create(String, String) method defined in the remote home interface, which would be defined as

<method>
<ejb-name>EmployeeService</ejb-name>
<method-intf>Home</method-intf>
<method-name>create</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>

and the create method that is defined in the local home interface which would be defined as

<method>
<ejb-name>EmployeeService</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>create</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>

The method-intf element can be used with all three Styles of the method element usage. For example, the following method element example could be used to refer to all the methods of the EmployeeService bean’s remote home interface.

<method>
<ejb-name>EmployeeService</ejb-name>
<method-intf>Home</method-intf>
<method-name>*</method-name>
</method>

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
ejb-name1The ejb-name element specifies an enterprise bean’s name. This name is assigned by the ejb-jar file producer to name the enterprise bean in the ejb-jar file’s deployment descriptor. The name must be unique among the names of the enterprise beans in the same ejb-jar file.

There is no architected relationship between the ejb-name in the deployment descriptor and the JNDI name that the Deployer will assign to the enterprise bean’s home.

The name for an entity bean with cmp-version 2.x must conform to the lexical rules for an NMTOKEN. The name for an entity bean with cmp-version 2.x must not be a reserved literal in EJB QL.

Example:

<ejb-name>EmployeeService</ejb-name>

method-intf?The method-intf element allows a method element to differentiate between the methods with the same name and signature that are multiply defined across the component and home interfaces (e.g, in both an enterprise bean’s remote and local interfaces; in both an enterprise bean’s home and remote interfaces, etc.)

The method-intf element must be one of the following:

<method-intf>Home</method-intf>
<method-intf>Remote</method-intf>
<method-intf>LocalHome</method-intf>
<method-intf>Local</method-intf>

method-name1The method-name element contains a name of an enterprise bean method or the asterisk (*) character. The asterisk is used when the element denotes all the methods of an enterprise bean’s component and home interfaces.
method-params?The method-params element contains a list of the fully-qualified Java type names of the method parameters.
method-param*The method-param element contains the fully-qualified Java type name of a method parameter.
container-transaction*The container-transaction element specifies how the container must manage transaction scopes for the enterprise bean’s method invocations. The element consists of an optional description, a list of method elements, and a transaction attribute. The transaction attribute is to be applied to all the specified methods.
description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
method+Same as <assembly-descriptor> <method-permission> <method>.
trans-attribute1The trans-attribute element specifies how the container must manage the transaction boundaries when delegating a method invocation to an enterprise bean’s business method.

The value of trans-attribute must be one of the following:

<trans-attribute>NotSupported</trans-attribute>
<trans-attribute>Supports</trans-attribute>
<trans-attribute>Required</trans-attribute>
<trans-attribute>RequiresNew</trans-attribute>
<trans-attribute>Mandatory</trans-attribute>
<trans-attribute>Never</trans-attribute>

exclude-list?The exclude list element specifies one or more methods which the Assembler marks to be uncallable.

If the method permission relation contains methods that are in the exclude list, the Deployer should consider those methods to be uncallable.

description?The description element is used to provide text describing the parent element. The description element should include any information that the enterprise bean ejb-jar file producer wants to provide to the consumer of the enterprise bean ejb-jar file (i.e., to the Deployer). Typically, the tools used by the enterprise bean ejb-jar file consumer will display the description when processing the parent element that contains the description.
method+Same as <assembly-descriptor> <method-permission> <method>.
ejb-client-jar?The optional ejb-client-jar element specifies a JAR file that contains the class files necessary for a client program to access the enterprise beans in the ejb-jar file.

<ejb-client-jar>employee_service_client.jar</ejb-client-jar>

3. Conclusion

Deployment plans provides additional information to map declared resources names, ejb names, security roles, JMS roles (if any) to actual resources in the server. The deployment plans also contain specific server settings and configurations. Deployment descriptors are necessary but are not always sufficient to deploy an asset on your server.

Dhruv Gupta

Dhruv holds Master degree in MCA and is OCPJP Certified Java EE Developer. He has been involved the wide variety of business application. Particularly always involved in J2EE technology and business domain as Finance. His areas of interest include Java EE, scalable architecture, object oriented design and In-Memory data grids. He loves writing about and evangelizing Java EE technologies. He is working as a software engineer in Finance domain where he is involved in projects based on Java J2EE technologies.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Priya
6 years ago

Very Informative !! A deployment descriptor is a configuration file for a web application or EJB application which is to be deployed to web or EJB container. Keep blogging.

Back to top button