You’ve written your bean class, interfaces, and deployment descriptor. How do you package them for deployment to any EJB container? You need a standard format that bundles everything together.
The EJB-JAR file is a standard Java archive (.jar) containing all the classes (bean class, home/remote/local interfaces, helpers) plus the ejb-jar.xml deployment descriptor. This single file is what you deploy to the container—it’s vendor-neutral and portable.
- Compile:
javacconverts.java→.classfor all your files - Package:
jar cvf MyBean.jar *.class ejb-jar.xmlcreates the archive - Deploy: Copy JAR to container’s deployment folder or use vendor tools
- Container verifies: Checks the JAR structure and generates EJB Object/Home Object
- Standard format: Any EJB container can read an EJB-JAR file
- Contains: Classes +
META-INF/ejb-jar.xml(deployment descriptor) - Optional: May include
META-INF/webservices.xmlor vendor-specific files - Vendor-neutral: Write once, deploy on any EJB container
- Built from: Home Interface, Remote Interface, Deployment Descriptor
- Builds into: EJB Verification & Generation (container processes the JAR)
- Related: EJB Client JAR (subset of files for clients)
- Contrasts with: Regular JAR (no
ejb-jar.xml, not deployable to EJB container)
- Missing
ejb-jar.xml: Container rejects the JAR—deployment fails - Classpath issues: All dependencies must be in the JAR or server classpath
- Vendor-specific files: Some containers need extra files in
META-INF/(e.g.,weblogic-ejb-jar.xml)