JBoss.org Community Documentation
The EJB 3.0 specification supports the usage of deployment descriptors to describe ejb metadata
or override most metadata described via annotations. The jboss.xml deployment descriptor describes
JBoss specific metadata, including remote and local JNDI names, cluster configuration, a security domain,
additional references, security principal, and container configuration. Annotations which define the ejb
(e.g. @Stateful
, @Remote
) cannot be overridden.
Take a look at META-INF/jboss.xml
.
jndi-name
element defines the remote JNDI binding for the ShoppingCartBean
stateful session bean.
This JNDI binding overrides the default binding or a binding specified through the @RemoteBinding
annotation.
Similarly, the local-jndi-name
element specifies the local JNDI binding.
clustered
element indicates that the ejb is clustered, with partition-name
and
load-balance-policy
specifying the cluster name and load balance policy, respectively.
These elements will override the parameters specified in the @Clustered
annotation.
In this example, you will see that the ShoppingCartBean
ejb is clustered.
security-domain
element specifies a security domain for the ejb, overriding
any security domain set through the @SecurityDomain
annotation. In this example,
you will see that a security domain is set through the jboss.xml deployment descriptor and unless a
Principal and Credential (i.e. user/password) is set in the client, requests to the ejb will fail
with a javax.ejb.EJBAccessException.
To build and run the example, make sure you have installed JBoss 5.x. See the Section 1.1, “JBoss Application Server 5.x” for details.
From the command prompt, move to the "jboss_deployment_descriptor" folder under the Section 1.3, “Set the EJB3_TUTORIAL_HOME”
Make sure the "all" server configuration of JBossAS-5.x is running
$ ant $ ant run run: [java] Attempting to buy 1 memory stick with incorrect password [java] Caught javax.ejb.EJBAccessException as expected [java] Setting user/password [java] bill is a shopper, so is allowed to buy [java] Buying 1 memory stick [java] Buying another memory stick [java] Buying a laptop [java] Print cart: [java] 2 Memory stick [java] 1 Laptop [java] bill is not a clerk, so is not allowed to price check [java] Caught EJBAccessException as expected [java] Checkout [java] Should throw an object not found exception by invoking on cart after @Remove method [java] Successfully caught no such object exception. [java] Caught javax.ejb.EJBAccessException, for SLSB, as expected [java] Now passing the correct user/password to access the SLSB [java] Successfully accessed SLSB
$ mvn clean install -PRunSingleTutorial