Can I deploy two beans in a single jar file? If so, how?

Doug Bell

Yes, multiple EJBs can be deployed in a single jar file. The deployment is somewhat different between EJB 1.0 and EJB 1.1.

In EJB 1.0 each bean has a separate serialized deployment descriptor. All of the bean classes and deployment descriptors are placed in the jar file along with the manifest file named META-INF/MANIFEST.MF. The manifest file must contain an entry for each bean that names the bean's deployment descriptor. For example, the following manifest is for a jar file that contains two deployment descriptors:

Name: BeanADD.ser
Enterprise-Bean: True

Name: dirname/BeanBDD.ser
Enterprise-Bean: True

Note that a blank line is required between the entries in the manifest file.

In EJB 1.1 and in the draft EJB 2.0 specification, instead of a manifest and serialized deployment descriptors there is a single shared XML deployment descriptor named META-INF/ejb-jar.xml. Within ejb-jar.xml there must be either a <session> or <entity> element for each bean in the jar file. For example, the following XML fragment is for a jar file that contains one entity and one session bean:

      ... other xml elements describing the bean's deployment properties ...
      ... other xml elements describing the bean's deployment properties ...

The EJB 2.0 draft specification for deployment descriptors differs from EJB 1.1 only in the addition of XML elements for describing additional bean properties.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact