Table of Contents
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:
Create the EJB classes and interfaces
Create the standard ejb-jar.xml deployment descriptor
Create a Geronimo-specific openejb-jar.xml deployment plan
Package the EJBs and deployment descriptors into an EJB JAR, or a directory tree laid out like an EJB JAR
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.
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”).
Geronimo expects the META-INF/ejb-jar.xml file to obey one of the following standard formats:
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>
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>
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>