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