Enterprise JavaBeans (ejb-jar.xml)

Enterprise JavaBean components are deployed using a ejb-jar.xml deployment descriptor. The high-level descriptor summary for EJB deployment descriptors is shown in Figure A-8. The following sections provide details on each section of the descriptor. In all the diagrams in this section, deployment elements that were introduced in the EJB 2.1 specification are labelled with a “2.1” indicator. All other elements were present in the 2.0 (and possibly earlier) version of the EJB specification.

The format for an empty ejb-jar.xml file is shown in Example A-8.

EJB deployment descriptor overview

Figure A-8. EJB deployment descriptor overview

Example A-8. EJB deployment descriptor header

<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                            http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
         version="2.1">
    . . .
</ejb-jar>

The example references the XML schema for the EJB 2.1 deployment descriptor from the default location on the http://java.sun.com server. To reference the EJB 2.0 DTD instead (e.g., if you are using a J2EE 1.3 application server like JBoss 3.x or an EJB 2.0 container plug-in), you should start your deployment descriptor with the following DOCTYPE element and no schema reference:

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> ...

Get Java Enterprise in a Nutshell, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.