Sunday, June 1, 2008

Classloading for Web Apps or EJBs on an Apps Svr

Question: How does the classloading happen for Web Apps or EJBs?

Answer: Usually all the popular application servers provide separate class-loaders for all the Web Applications and EJBs, which have been deployed separately on that application server. However, if you package more than one Web Apps and/or EJBs in an EAR - Enterprise Archive and deploy that EAR file on the application server, then the application server will provide only one class-loader. The idea is to provide one class-loader for each separate deployment.

The class-loader(s) provided by the application server are loaded into the memory by the default Application Classloader provided by Java. In fact, the classloaders provided by the application servers derive the same default Java-supplied Application Classloader. Once loaded, these apps server supplied classloaders take the responsibility of loading all the classes (which are not part of the Core Java classes - already loaded by the Java-supplied Bootstrap classloader OR part of the Extension classes - already loaded by the Java-supplied Extension Classloader) of the Web App(s) and/or EJB(s).

This feature makes the deployement process of the applications on the underlying Application Server faster as all the application-specific classloaders (Apps Server supplied) load the classes of the corresponding applications concurrently.


No comments: