JBoss.org Community Documentation

Chapter 32. Configuring Stateless Session Beans with deployment descriptors in EJB3

CalculatorBean is defined as a stateless session bean through the <session> and <session-type> elements. This marks the class as a stateless bean and the deployer will deploy that class as a stateless bean EJB container.

CalculatorBean also implements two interfaces. One is the business-remote interface of the EJB the other is the business-local interface. Take a look at org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorRemote. To define this as the business-remote interface of Calculator bean you specify the interface with the <remote> tag. Similarly for org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorLocal you need to specify the business-local interface with the <local> tag. Here's the META-INF/ejb-jar.xml:

			
<session>
         <ejb-name>Calculator</ejb-name>
         <business-local>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorLocal</business-local>
         <business-remote>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorRemote</business-remote>
         <ejb-class>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
</session>
			
		

Note

There's a very important difference between the remote and a business-remote interface. The EJB2.x remote interfaces, which extend from EJBObject, are referred through the <remote> tag in the ejb-jar.xml. On the other hand, the EJB3 style Plain Old Java Interface which is implemented by your EJB3 style POJO bean is known as the business-remote interface and is represented by the @Remote and it's corresponding <business-remote> tag in ejb-jar.xml. Similar is the case with <local> and the <business-local> tags in ejb-jar.xml.

JNDI Bindings through deployment descriptor :

The Calculator bean will have two JNDI bindings for the remote and Local interface. The META-INF/jboss.xml through the <jndi-name> and the <local-jndi-name> specifies the jndi-name for the remote and the local interfaces, respectively:

				
<session>
         <ejb-name>Calculator</ejb-name>
         <jndi-name>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorRemote</jndi-name>
         <local-jndi-name>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorLocal</local-jndi-name>
</session>