| bea.com | products | dev2dev | support | askBEA |
![]() |
![]() |
|
|||||||
| e-docs > WebLogic Server > Programming WebLogic Enterprise JavaBeans > weblogic-ejb-jar.xml Document Type Definitions |
|
Programming WebLogic Enterprise JavaBeans
|
weblogic-ejb-jar.xml Document Type Definitions
The following sections describe the EJB 1.1 and EJB 2.0 deployment descriptor elements found in the weblogic-ejb-jar.xml file, the weblogic-specific XML document type definitions (DTD) file. Use these definitions to create the WebLogic-specific weblogic-ejb-jar.xml file that is part of your EJB deployment.
The EJB deployment descriptors contain structural and application assembly information for an enterprise bean. You specify this information by specifying values for the deployment descriptors in three EJB XML DTD files. These files are:
You package these three XML files with the EJB and other classes into a deployable EJB component, usually a JAR file, called ejb.jar.
The ejb-jar.xml file is based on the deployment descriptors found in Sun Microsystems's ejb.jar.xml file. The other two XML files are weblogic-specific files that are based on the deployment descriptors found in weblogic-ejb-jar.xml and weblogic-cmp-rdbms-jar.xml.
When you edit or create XML deployment files, it is critical to include the correct DOCTYPE header for the deployment file. In particular, using an incorrect PUBLIC element within the DOCTYPE header can result in parser errors that may be difficult to diagnose.
WebLogic provides a public location for you to access the correct text for the WebLogic Server-specific DTD file, weblogic-ejb-jar.xml. However, an identical version of this DTD file is embedded in WebLogic Server for internal use. weblogic.ejbc uses this file when the XML parser checks the sequence of the deployment descriptors files.
The correct text for the PUBLIC elements for the WebLogic Server-specific weblogic-ejb-jar.xml file are as follows.
The correct text for the PUBLIC elements for the Sun Microsystem-specific ejb-jar.xml file are as follows.
|
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' |
|
|
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' |
For example, the entire DOCTYPE header for a weblogic-ejb-jar.xml file is as follows:
<!DOCTYPE weblogic-ejb-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 7.0.0 EJB//EN' 'http://www.bea.com/servers/wls700/dtd/weblogic-ejb-jar.dtd'>
XML files with incorrect header information may yield error messages similar to the following, when used with a utility that parses the XML (such as ejbc):
SAXException: This document may not have the identifier `identifier_name'
identifier_name generally includes the invalid text from the PUBLIC element.
Document Type Definitions (DTDs) for Validation
The contents and arrangement of elements in your XML files must conform to the Document Type Definition (DTD) for each file you use. WebLogic Server ignores the DTDs embedded within the DOCTYPE header of XML deployment files, and instead uses the DTD locations that were installed along with the server. However, the DOCTYPE header information must include a valid URL syntax in order to avoid parser errors.
Note: Most browsers do not display the contents of files having the .dtd extension. To view the DTD file contents in your browser, save the links as text files and view them with a text editor.
The following links provide the new public DTD locations for the weblogic-ejb-jar.xml deployment files used with the WebLogic Server:
The following links provide the public DTD locations for the ejb-jar.xml deployment files used with WebLogic Server:
http://www.java.sun.com/dtd/ejb-jar_2_0.dtd contains the DTD for the standard ejb-jar.xml deployment file, required for all EJBs. This DTD is maintained as part of the JavaSoft EJB 2.0 specification; refer to the JavaSoft specification for information about the elements used in ejb-jar.dtd.
Note: Refer to the appropriate JavaSoft EJB specification for a description of the ejb-jar.xml deployment descriptors.
Changed Deployment Elements in WebLogic Server 7.0 EJB
These changes were made to weblogic-ejb-jar.xml in WebLogic Server 7.0:
2.0 weblogic-ejb-jar.xml Deployment Descriptor File Structure
The WebLogic Server 7.0 weblogic-ejb-jar.xml deployment descriptor file describes the elements that are unique to WebLogic Server. Although you can use both WebLogic 7.0 and WebLogic 6.0 deployment descriptor elements in the EJB container, the WebLogic Server 7.0 version of weblogic-ejb-jar.xml is different from the version shipped with WebLogic Server Version 6.0.
The top level elements in the WebLogic Server 7.0 weblogic-ejb-jar.xml are as follows:
2.0 weblogic-ejb-jar.xml Deployment Descriptor Elements
|
Requires the server to throw a RemoteException when a stateful session bean instance is currently handling a method call and another (concurrent) method call arrives on the server. |
|
The allow-concurrent-calls element specifies whether a stateful session bean instance allows concurrent method calls. By default, allows-concurrent-calls is false. However, when this value is set to true, the EJB container blocks the concurrent method call and allows it to proceed when the previous call has completed.
See stateful-session-descriptor
allow-remove-during-transaction
The allow-remove-during-transaction element specifies that the remove method on a stateful session bean can be invoked within a transaction context.
Stateful session beans implementing the Synchronization interface should not use this tag and then call remove before the transaction ends. If this is done the EJB container will not invoke the synchronization callbacks.
See stateful-session-descriptor
The cache-between-transactions element, formerly the db-is-shared element, specifies whether the EJB container will cache the persistent data of an entity bean across (between) transactions.
The cache-between-transactions element applies only to entity beans. Specify True to enable the EJB container performs long term caching of the data. Specify False to enable the EJB container to perform short term caching of the data. This is the default setting.
A Read-Only bean ignores the value of the cache-between-transactions element because WebLogic Server always performs long term caching of Read-Only data.
See Caching Between Transactions for more information.
See persistence.
The cache-type element specifies the order in which EJBs are removed from the cache. The values are:
The minimum cache size for NRU is 8. If max-beans-in-cache is less than 3, WebLogic Server uses a value of 8 for cache-type.
The following example shows the structure of the cache-type element.
<stateful-session-cache>
<cache-type>NRU</cache-type>
</stateful-session-cache>
The client-authentication element specifies whether the EJB supports or requires client authentication.
The client-cert-authentication element specifies whether the EJB supports or requires client certificate authentication at the transport level.
The clients-on-same-server attribute determines whether WebLogic Server sends JNDI announcements for this EJB when it is deployed. When this attribute is "false" (the default), a WebLogic Server cluster automatically updates its JNDI tree to indicate the location of this EJB on a particular server. This ensures that all clients can access the EJB, even if the client is not collocated on the same server.
You can set clients-on-same-server to "true" when you know that all clients that will access this EJB will do so from the same server on which the bean is deployed. In this case, a WebLogic Server cluster does not send JNDI announcements for this EJB when it is deployed. Because JNDI updates in a cluster utilize multicast traffic, setting clients-on-same-server to "true" can reduce the startup time for very large clusters.
See Optimization for Collocated Objects in Using WebLogic Server Clusters for more information on collocated EJBs.
The following example enables pass-by-value for EJB methods:
<weblogic-enterprise-bean>
<ejb-name>AccountBean</ejb-name>
...
<clients-on-same-server>true</clients-on-same-server>
</weblogic-enterprise-bean>
The concurrency-strategy element specifies how the container should manage concurrent access to an entity bean. Set this element to one of four values:
See EJB Concurrency Strategy for more information on the Exclusive and Database locking behaviors. See Read-Only Multicast Invalidation for more information about read-only entity EJBs.
The following entry identifies the AccountBean class as a read-only entity EJB:
<weblogic-enterprise-bean>
<ejb-name>AccountBean</ejb-name>
<entity-descriptor>
<entity-cache>
<concurrency-strategy>ReadOnly</concurrency-strategy>
</entity-cache>
</entity-descriptor>
</weblogic-enterprise-bean>
The confidentiality element specifies the transport confidentiality requirements for the EJB. Using the confidentiality element ensures that the data is sent between the client and server in such a way as to prevent other entities from observing the contents.
The connection-factory-jndi-name element specifies the JNDI name of the JMS ConnectionFactory that the MessageDriven Bean should look up to create its queues and topics. If this element is not specified, the default is the weblogic.jms.MessageDrivenBeanConnectionFactory in config.xml.
The following example shows the structure of the connection-factory-jndi-name element:
<message-driven-descriptor>
<connection-factory-jndi-name>weblogic.jms.MessageDrivenBean
ConnectionFactory</connection-factory-jndi-name>
</message-driven-descriptor>
Set the delay-updates-until-end-of-tx element to true (the default) to update the persistent store of all beans in a transaction at the completion of the transaction. This setting generally improves performance by avoiding unnecessary updates. However, it does not preserve the ordering of database updates within a database transaction.
If your datastore uses an isolation level of TRANSACTION_READ_UNCOMMITTED, you may want to allow other database users to view the intermediate results of in-progress transactions. In this case, set delay-updates-until-end-of-tx to false to update the bean's persistent store at the conclusion of each method invoke. See ejbLoad() and ejbStore() Behavior for Entity EJBs for more information.
Note: Setting delay-updates-until-end-of-tx to false does not cause database updates to be "committed" to the database after each method invoke; they are only sent to the database. Updates are committed or rolled back in the database only at the conclusion of the transaction.
The following example shows a delay-updates-until-end-of-tx stanza.
<entity-descriptor>
<persistence>
<delay-updates-until-end-of-tx>false</delay-updates-until-end-of-tx>
</persistence>
</entity-descriptor>
The description element is used to provide text that describes the parent element.
The following example specifies the description element.
<description>Contains a description of parent element</description>
|
Required in message-driven-descriptor. |
|
The destination-jndi-name element specifies the JNDI name used to associate a message-driven bean with an actual JMS Queue or Topic deployed in the WebLogic Server JNDI tree.
See message-driven-descriptor.
|
Required element in method stanza. The name must conform to the lexical rules for an NMTOKEN. |
|
ejb-name specifies the name of an EJB to which WebLogic Server applies isolation level properties. This name is assigned by 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. The enterprise bean code does not depend on the name; therefore the name can be changed during the application-assembly process without breaking the enterprise bean's function. There is no built-in relationship between the ejb-name in the deployment descriptor and the JNDI name that the deployer will assign to the enterprise bean's home.
See method.
The ejb-reference-description element maps the JNDI name in the WebLogic Server of an EJB that is referenced by the bean in the ejb-reference element.
The ejb-reference-description stanza is shown here:
<ejb-reference-description>
<ejb-ref-name>AdminBean</ejb-ref-name>
<jndi-name>payroll.AdminBean</jndi-name>
</ejb-reference-description>
The ejb-ref-name element specifies a resource reference name. This element is the reference that the EJB provider places within the ejb-jar.xml deployment file.
The ejb-ref-name stanza is shown here:
<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>AdminBean</ejb-ref-name>
<jndi-name>payroll.AdminBean</jndi-name>
</ejb-reference-description>
</reference-descriptor>
ejb-local-reference-description
The ejb-local-reference-description element maps the JNDI name of an EJB in the WebLogic Server that is referenced by the bean in the ejb-local-ref element.
The following example shows the ejb-local-reference-description element.
<ejb-local-reference-description>
<ejb-ref-name>AdminBean</ejb-ref-name>
<jndi-name>payroll.AdminBean</jndi-name>
</ejb-local-reference-description>
By default, EJB methods called from within the same application (EAR) pass arguments by reference. This increases the performance of method invocation because parameters are not copied.
If you set enable-call-by-reference to False, parameters to the EJB methods are copied (pass-by-value) in accordance with the EJB 1.1 specification. Pass by value is always necessary when the EJB is called remotely (not from within the same application).
The following example enables pass-by-value for EJB methods:
<weblogic-enterprise-bean>
<ejb-name>AccountBean</ejb-name>
...
<enable-call-by-reference>false</enable-call-by-reference>
</weblogic-enterprise-bean>
The optional enable-dynamic-queries element must be set to true to enable dynamic queries. Dynamic queries are only available for use with EJB 2.0 CMP beans.
The following example enables dynamic queries:
<enable-dynamic-queries>True</enable-dynamic-queries>
The entity-cache element defines the following options used to cache entity EJB instances within WebLogic Server:
See EJB Life Cycle for a general discussion of the caching services available in WebLogic Server.
The entity-cache stanza is shown here:
<entity-descriptor>
<entity-cache>
<max-beans-in-cache>...</max-beans-in-cache>
<idle-timeout-seconds>...</idle-timeout-seconds>
<read-timeout-seconds>...<read-timeout-seconds>
<concurrency-strategy>...</concurrency-strategy>
</entity-cache>
<persistence>...</persistence>
<entity-clustering>...</entity-clustering>
</entity-descriptor>
The entity-cache-name element refers to an application level entity cache that the entity bean uses. An application level cache is a cache that may be shared by multiple entity beans in the same application.
For more information about the weblogic-application.xml file, see the application deployment descriptors.
See entity-cache-ref.
|
The entity-cache-name element in the entity-cache-ref stanza must contain the name of the application level cache. |
|
The entity-cache-ref element refers to an application level entity cache which can cache instances of multiple entity beans that are part of the same application. Application level entity caches are declared in the weblogic-application.xml file.
Use the concurrency-strategyto define the type of concurrency you want the bean to use. The concurrency-strategy must be compatible with the application level cache's caching strategy. For example, an Exclusive cache only supports banes with a concurrency-strategy of Exclusive. While a MultiVersion cache supports the Database, ReadOnly, and Optimistic concurrency strategies.
The entity-cache-ref stanza is shown here:
<entity-cache-ref>
<entity-cache-name>AllEntityCache</entity-cache-name>
<concurrency-strategy>ReadOnly</concurrency-strategy>
<estimated-bean-size>20</estimated-bean-size>
</entity-cache-ref>
The entity-clustering element uses the following options to specify how an entity bean will be replicated in a WebLogic cluster:
The following excerpt shows the structure of a entity-clustering stanza:
<entity-clustering>
<home-is-clusterable>true</home-is-clusterable>
<home-load-algorithm>random</home-load-algorithm>
<home-call-router-class-name>beanRouter</home-call-router-class-name>
</entity-clustering>
The entity-descriptor element specifies the following deployment parameters that are applicable to an entity bean:
The following example shows the structure of the entity-descriptor stanza:
<entity-descriptor>
<entity-cache>...</entity-cache>
<persistence>...</persistence>
<entity-clustering>...</entity-clustering>
</entity-descriptor>
The estimated-bean-size- element specifies the estimated average size of the instances of an entity bean in bytes. This is the average number of byte of memory that is consumed by each instance.
Use the estimated-bean-size element when the application level cache you use to cache beans is also specified in terms of bytes and megabytes.
Although you may not know the exact number of bytes consumed by the entity bean instances, specifying a size allows you to give some relative weight to the beans that share a cache. at one time.
For example, suppose bean A ad bean B share a cache, called AB-cache, that has a size of 1000 bytes and the size of A is 10 bytes and the size of B is 20 bytes, then the cache can hold at most 100 instances of A and 50 instances of B. If 100 instance s of A are cached, this implies that 0 instances of B are cached.
See entity-cache-ref.
The externally-defined element indicates that a particular security role is defined externally in a security realm, outside of the deployment descriptor. Because the security role and it's principal-name mapping is defined elsewhere, principal-names are not to be specified in the deployment descriptor. This tag is used as an indicative placeholder instead of a set of principal-name elements.
The finders-load-bean element determines whether WebLogic Server loads the EJB into the cache after a call to a finder method returns a reference to the bean. If you set this element to true, WebLogic Server immediately loads the bean into the cache if a reference to a bean is returned by the finder. If you set this element to false, WebLogic Server does not automatically load the bean into the cache until the first method invocation; this behavior is consistent with the EJB 1.1 specification.
The following entry specifies that EJBs are loaded into the WebLogic Server cache automatically when a finder method returns a reference to the bean:
<entity-descriptor>
<persistence>
<finders-load-bean>true</finders-load-bean>
</persistence>
</entity-descriptor>
The global-role element indicates that a particular security role is defined "globally" in a security realm. Because the security role and its principal-name mapping is defined elsewhere, principal-names are not to be specified in the deployment descriptor. This tag is used as an indicative placeholder instead of a set of principal-name elements.
home-call-router-class-name specifies the name of a custom class to use for routing bean method calls. This class must implement weblogic.rmi.cluster.CallRouter(). If specified, an instance of this class is called before each method call. The router class has the opportunity to choose a server to route to based on the method parameters. The class returns either a server name or null, which indicates that the current load algorithm should select the server.
See entity-clustering and stateful-session-clustering.
Use home-is-clusterable to specify whether the home interface of an entity, stateless session, or stateful session bean is clustered.
When home-is-clusterable is true for an EJB deployed to a cluster, each server instance binds the bean's home interface to its cluster JNDI tree under the same name. When a client requests the bean's home from the cluster, the server instance that does the look-up returns a EJBHome stub that has a reference to the home on each server.
When the client issues a create() or find() call, the stub routes selects a server from the replica list in accordance with the load balancing algorithm, and routes the call to the home interface on that server. The selected home interface receives the call, and creates a bean instance on that server instance and executes the call, creating an instance of the bean.
See entity-clustering.
home-load-algorithm specifies the algorithm to use for load balancing between replicas of the EJB home. If this element is not defined, WebLogic Server uses the algorithm specified by the server element, weblogic.cluster.defaultLoadAlgorithm.
You can define home-load-algorithm as one of the following values:
See entity-clustering and stateful-session-clustering.
The idempotent-methods element defines list of methods which are written in such a way that repeated calls to the same method with the same arguments has exactly the same effect as a single call. This allows the failover handler to retry a failed call without knowing whether the call actually compiled on the failed server. When you enable idempotent-methods for a method, the EJB stub can automatically recover from any failure as long as it can reach another server hosting the EJB.
To enable clustering, see entity-clustering, stateful-session-clustering, and stateless-clustering.
The methods on stateless session bean homes and read-only entity beans are automatically set to be idempotent. It is not necessary to explicitly specify them as idempotent.
The method stanza can contain the elements shown here:
<idempotent-method>
<method>
<description>...</description>
<ejb-name>...</ejb-name>
<method-intf>...</method-intf>
<method-name>...</method-name>
<method-params>...</method-params>
</method>
</idempotent-method>
The identity-assertion element specifies whether the EJB supports or requires identity assertion.
idle-timeout-seconds defines the maximum length of time a stateful EJB should remain in the cache. After this time has elapsed, WebLogic Server removes the bean instance if the number of beans in cache approaches the limit of max-beans-in-cache. The removed bean instances are passivated. See EJB Life Cycle for more information.
Note: Although idle-timeout-seconds appears in the entity-cache stanza, WebLogic Server 7. 0 SP01, SP02, SP03, and SP04 do not use its value in managing the lifecycle of entity EJBs—in those service pecks, idle-timeout-seconds has no effect on when entity beans are removed from cache.
The following entry indicates that the stateful session EJB, AccountBean, should become eligible for removal if max-beans-in-cache is reached and the bean has been in cache for 20 minutes:
<weblogic-enterprise-bean>
<ejb-name>AccountBean</ejb-name>
<stateful-session-descriptor>
<stateful_session-cache>
<max-beans-in-cache>200</max-beans-in-cache>
<idle-timeout-seconds>1200</idle-timeout-seconds>
</stateful-session-cache>
</stateful-session-descriptor>
</weblogic-enterprise-bean>
The iiop-security-descriptor element specifies security configuration parameters at the bean-level. These parameters determine the IIOP security information contained in the IOR.
The iiop-security-descriptor stanza can contain the elements shown here
<iiop-security-descriptor>
<transport-requirements>...</transport-requirements>
<client-authentication>supported<client-authentication>
<identity-assertion>supported</identity-assertion>
</iiop-security-descriptor>