5.6. JOnAS Class Loaders

The JOnAS class loader hierarchy that allows the deployment of EAR applications without placing the EJB JAR in the WEB-INF/lib directory consists of the following:

5.6.1. EAR Class Loader

The EAR class loader is responsible for loading the EAR application. There is only one EAR class loader per EAR application. This class loader is the child of the application class loader, thus making it visible to the JOnAS classes.

5.6.2. EJB Class Loader

The EJB class loader is responsible for loading all the EJB JARs of the EAR application, thus all the EJBs of the same EAR application are loaded with the same EJB classloader. This class loader is the child of the EAR class loader.

5.6.3. WEB Class Loader

The WEB class loader is responsible for loading the Web components. There is one WEB class loader per WAR file, and this class loader is the child of the EJB class loader. Using this class loader hierarchy (the EJB class loader is the parent of the WEB class loader) eliminates the problem of visibility between classes when a WEB component tries to reference EJBs; the classes loaded with the WEB class loader are definitely visible to the classes loaded by its parent class loader (EJB class loader).

The compliance of the class loader of the web application to the Java 2 delegation model can be changed by using the jonas-web.xml file. This is described in Chapter 17 Defining the Web Deployment Descriptor.

If the java2-delegation-model element is set to false, the class loader of the web application looks for the class in its own repository before asking its parent class loader.