The basic idea of this approach is that your Servlets and EJBs are together in your war file as one app.
- No classloader boundries between Serlvets & EJBs
- EJBs and Servlets can share all third-party libraries (like Spring!), no ear required.
- Can put the web.xml and ejb-jar.xml in the same archive (the war file).
- EJBs can see Serlvet classes and vice versa.
Not quite J2EE
This is very different than J2EE as defined by the spec as there aren't several levels of separation and heirarchy. This is going to take some getting used to and it should be understood that this style of packaging isn't J2EE compliant.
J2EE classloading rules:
- You cannot ever have ejbs and servlets in the same classloader.
- Three classloader minimum; a classloader for the ear, one for each ejb jar, and one for each war file.
- Servlets can see EJBs, but EJBs cannot see Servlets.
To pull that off, J2EE has to kill you on packaging:
- You cannot have EJB classes and Servlet classes in the same archive.
- You need at least three archives to combine servlets and ejbs; 1 ear containing 1 ejb jar and 1 servlet war.
- Shared libraries must go in the ear and be included in a specially formatted 'Class-Path' entry in the ear's MANIFEST file.
Critically speaking, forcing more than one classloader on an application is where J2EE "jumps the shark" for a large majority of people's needs.