Chapter 12. Enterprise Java Beans (EJB JARs) [DRAFT (1.0)]

Table of Contents

12.1. Creating an EJB JAR
12.1.1. ejb-jar.xml Format
12.2. The Geronimo EJB Deployment Plan
12.2.1. Typical Contents of the Geronimo EJB Deployment Plan
12.3. Structure of the Deployment Plan
12.3.1. Customizing the Class Path
12.3.2. Common Settings For All CMP Entity Beans
12.3.3. Session Beans
12.3.4. Entity Beans
12.3.5. Message-Driven Beans
12.3.6. Resolving References from EJBs
12.3.7. Resolving Container-Managed Relationships
12.3.8. Security Settings
12.3.9. Module-Scoped Services

Geronimo supports Enterprise JavaBeans based on the EJB 2.1 specification, with backward compatibility to EJB 2.0 and EJB 1.1. EJBs have full access to application components and resources deployed at the application or server level, and may deploy custom resources at the module (EJB JAR) level as well.

Deploying EJBs to Geronimo typically involves several steps:

  1. Create the EJB classes and interfaces

  2. Create the standard ejb-jar.xml deployment descriptor

  3. Create a Geronimo-specific openejb-jar.xml deployment plan

  4. Package the EJBs and deployment descriptors into an EJB JAR, or a directory tree laid out like an EJB JAR

  5. Use the deployment tool described in Section 10.4, “The Deploy Tool” to deploy the EJB JAR (or an EAR containing the EJB JAR) into the server

The process of developing EJBs and the standard ejb-jar.xml deployment descriptor should be familiar already. After a brief review of what Geronimo expects from an EJB JAR, this chapter focuses mainly on the contents of the Geronimo openejb-jar.xml deployment plan.

12.1. Creating an EJB JAR

Geronimo doesn't have any special requirements on EJB JAR files -- any EJB JAR produced according to the standard process should work in Geronimo. However, there are a couple points to note:

  • Geronimo requires that every EJB JAR file has a standard META-INF/ejb-jar.xml deployment descriptor. This may be for EJB 1.1, EJB 2.0, or EJB 2.1, and should follow the appropriate XML format (see below).

  • If the EJB JAR file is included in an application EAR, then Geronimo will respect Class-Path entries in the META-INF/MANIFEST.MF file of the EJB JAR. Any JARs referenced there should also be packaged within the EAR, and paths to JAR files will be resolved relative to the position of the EJB JAR file in the EAR. If the EJB JAR file is not included in an EAR, then manifest class path entries will be ignored. In either case, external libraries can also be placed in the Geronimo server repository and referenced with dependency elements in the Geronimo deployment plan (see Section 12.3.1, “Customizing the Class Path”).

12.1.1. ejb-jar.xml Format

Geronimo expects the META-INF/ejb-jar.xml file to obey one of the following standard formats:

EJB 1.1

Defined by the DTD at http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd,an EJB 1.1 deployment descriptor looks like this:

<?xml version="1.0" encoding="UTF-8"?>

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

<ejb-jar>
  ...
</ejb-jar>
EJB 2.0

Defined by the DTD at http://java.sun.com/dtd/ejb-jar_2_0.dtd, an EJB 2.0 deployment descriptor looks like this:

<?xml version="1.0" encoding="UTF-8"?>

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

<ejb-jar>
  ...
</ejb-jar>
EJB 2.1

Defined by the XML schema at http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd, an EJB 2.1 deployment descriptor looks like this:

<?xml version="1.0" encoding="UTF-8"?>

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