Jboss.xml Deployment Descriptor

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, @RemoteInterface) cannot be ovveridden.

JBoss.xml

Take a look at JBoss.xml.

The jndi-name element defines the remote JNDI binding for the ShoppingCart stateful session bean. This JNDI binding overrides the default binding or a binding specified through the @RemoteBinding annotation. Similiarly, the local-jndi-name element specifies the local JNDI binding. </p><p> The clustered element indicates that the ejb is clustered, with partition-name and load-balance-policy specifying the cluster name and load balance policy, respectively. The latter elements will override the parameters specified in the @Clustered annotation. In this example, you will see that the ShoppingCart ejb is clustered. If you build and run this example (see below) with the default server configuration, the deployment will fail, as the default server configuration does not support clustering. </p><p> The 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.

Building and Running

To build and run the example, make sure you have ejb3.deployer installed in JBoss 4.0.x and have JBoss running. See the reference manual on how to install EJB 3.0.
Unix:    $ export JBOSS_HOME=<where your jboss 4.0 distribution is>
Windows: $ set JBOSS_HOME=<where your jboss 4.0 distribution is>
$ ant
$ ant run

run:
     [java] Attempting to buy 1 memory stick with no user/password
     [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] 3     Memory stick
     [java] 1     Laptop
     [java] bill is not a clerk, so is not allowed to price check
     [java] Caught SecurityException as expected
     [java] Checkout
     [java] Should throw an object not found exception by invoking on cart after @Remove method
     [java] Exception in thread "main" javax.ejb.EJBNoSuchObjectException: Could not find Stateful bean: a1616c-oseo5o-eabsujnb-1-eabtkmic-7
}}}