- The EJB JAR modules and Web WAR modules comprising an application should be packaged together in the same EAR module.
- When a Web module accesses an EJB module, you should not package the EJB interfaces and stubs in the WAR modules. Thanks to the class loading architecture, EJB stubs and interfaces are visible by default to WAR modules.
- Utility classes used by a single Web module should be placed within its WEB-INF/lib folder.
- Utility classes used by multiple modules within an application should be placed at the root of the EAR file as Utility Projects, so they are accessible both by servlets and EJBs.
- Utility classes used by multiple applications can be placed on a directory referenced through a shared library definition.
J2EE applicaiton packaging recommendations
Here are some basic rules to consider when packaging an enterprise application: