Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: The article was purely J2EE-oriented. Now a bit more about JEE6

...

The basic idea of this approach is that your Servlets and EJBs are together in your war WAR file as one app.

  • No classloader boundries between Serlvets & Servlets and EJBs
  • EJBs and Servlets can share all third-party libraries (like Spring!) , - no ear EAR required.
  • Can put the web.xml and ejb-jar.xml in the same archive (the war WAR file).
  • EJBs can see Serlvet Servlet classes and vice versa.

Not quite J2EE (it is truly JEE6)

This is very different than J2EE as defined by the spec or Java EE 5 as there aren't several levels of separation and heirarchyclassloader hierarchy. This is going to take some getting used to and it should be understood that this style of packaging isn't J2EE compliant. Who would care tough as it is a feature of Java EE 6 we would've been waiting for so long.

J2EE classloading rules:

  • You cannot ever have ejbs 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 WAR file.
  • Servlets can see EJBs, but EJBs cannot see Servletsservlets.

To pull that off, J2EE has to kill you on packaging:

...

  • You need at least three archives to combine servlets and ejbs; 1 ear EAR containing 1 ejb EJB jar and 1 servlet warWAR.
  • Shared libraries must go in the ear EAR and be included in a specially formatted 'Class-Path' entry in the earEAR'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.

...