The ejb-jar.xml file must include a directive pointing to the DTD. The following code snip-
pet is an example of this directive:
<!DOCTYPE ejb-jar PUBLIC “-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN” “http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd”>
This line must appear at the top of every ejb-jar.xml file.
The outermost tag in the ejb-jar.xml file is <ejb-jar> . Everything will be contained within
this tag. You will have two main sections within this tag, one to define the EJB structural infor-
mation, contained inside the <enterprise-beans> tag, and a second section to define the
application assembly information, contained inside the <assembly-descriptor> tag.
You describe the dependencies of a session bean with an entry inside the <enterprise-beans>
tag. The following code snippet gives an example of this description:
Makes calculations related to a loan
This is a basic descriptor for our session bean. Each session bean in the jar file will have an
entry similar to this in the ejb-jar.xml file. The <ejb-name> tag identifies the name under
which the home interface will be kept by Java Naming and Directory Interface (JNDI). JNDI
provides a standard method for accessing named objects. This is the name needed to look it up.
It is arbitrary, however it must be unique within the application. Many times a prefix will be
used to avoid naming collisions with other EJB packages, for example,
The <home> , <remote> , and <ejb-class> tags all contain the fully qualified classpath to their
respective interface or class. The <session-type> tag can contain only two values, Stateless
or Stateful . This identifies whether you have decided to include conversational state in the
The last tag you see is <transaction-type> . It can hold two possible values— Container or
Bean . You have seen that it is possible to allow the container to manage all of the transactions,
and that each individual bean participates in the transactions. This tag specifies whether to let
the container take these responsibilities or have the bean handle them itself. For our example,
the container will handle all of the dirty work.