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

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:

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: