Experience in App Class Loader

xiaoxiao2021-03-06  106

Some thoughts on app class loader [The main reference article AppClassLoader AppClassLoader is the famous Java line of Lao Robbin]

I have never seen Java deep adventures, but I have heard some discussions about Class Loader. I have seen the App Class Loader article written by the Robbin brother. I have a slight summary of my own words.

A Java system's operation process allows the simultaneous existence of different JVM Class Loader to understand the relationship between different loaders, as shown below

App Class Loader | ----- EJB CLASS Loader | ----- Web App Class Loader

The App Class Loader level is global visible, and the two Loaders under which it belongs to only do not interfere with each other.

App Class Loader's Loading order is jre / lib / * => jre / lib / ext / * => jre / class / * => classpath / *

Web App Class Loader's Loading range in Web-INF / LIB / * and Web-INF / CLASSES / * They will start looking and transfer the Class / Jar / LIB required in the Loading range, if it fails, only Loading responsibility Hand it to App Class Loader, this is the so-called Class Loader inheritance relationship

The Loading range of EJB Class Loader is limited to JAR or EAR. App Server creates an instance of an EJB Class Loader for each EJB package file, for example: When you release hello.jar, two JARs in World.jar, the system creates two instances of EJB Class Loader, and go to LOAD two EJB package, so hello.jar can't see any files other than itself. In addition, if you want to call the name of the class library other than the JAR package, you need to define class-path in the manifest file of the JAR package: log4j.jar hibernate2.jar

This article explains everyone may have a little strange Class Loader has hierarchical inheritance relationship, The Visability of USABLE CLASS / JARS IS Defined by The Class Loader And All ITS Ancestors. This concept is important in J2EE and needs to be understood.

转载请注明原文地址:https://www.9cbs.com/read-103626.html

New Post(0)