j2ee容器类加载机制实例演示
所属分类 tomcat
浏览量 1286
tomcat8.5.32
获取jsp的类加载信息
public static List getClassLoaderList(Class cls) {
if (cls == null) {
return null;
}
ClassLoader cl = cls.getClassLoader();
List list = new ArrayList();
while (cl != null) {
list.add(cl);
cl = cl.getParent();
}
return list;
}
[
"org.apache.jasper.servlet.JasperLoader@70c756b6",
"ParallelWebappClassLoader\r\n context: ROOT\r\n delegate: false\r\n----------> Parent Classloader:\r\njava.net.URLClassLoader@1218025c\r\n",
"java.net.URLClassLoader@1218025c",
"sun.misc.Launcher$AppClassLoader@42a57993",
"sun.misc.Launcher$ExtClassLoader@6b143ee9"
]
public class org.apache.jasper.servlet.JasperLoader extends java.net.URLClassLoader
package org.apache.catalina.loader;
public class ParallelWebappClassLoader extends WebappClassLoaderBase {
public abstract class WebappClassLoaderBase extends URLClassLoader
protected boolean delegate = false;
delegate 具体含义
Should this class loader delegate to the parent class loader before searching its own repositories
(i.e. the usual Java2 delegation model)?
If set to false,this class loader will search its own repositories first,
and delegate to the parent only if the class or resource is not found locally.
Note that the default, false, is the behavior called for by the servlet specification.
URLClassLoader
public URL[] getURLs()
返回具体的类加载路径
org.apache.jasper.servlet.JasperLoader jsp加载器
TOMCAT_HOME/work/Catalina/localhost/ROOT/
ParallelWebappClassLoader web应用加载器
TOMCAT_HOME/webapps/$WEBAPP/WEB-INF/classes
TOMCAT_HOME/webapps/$WEBAPP/WEB-INF/lib/*.jar
java.net.URLClassLoader@1218025c tomcat容器加载器
TOMCAT_HOME/lib
TOMCAT_HOME/lib/*.jar
sun.misc.Launcher$AppClassLoader@42a57993 tomcat 启动类加载器
TOMCAT_HOME/bin/bootstrap.jar
TOMCAT_HOME/bin/tomcat-juli.jar
sun.misc.Launcher$ExtClassLoader@6b143ee9 jdk 加载器
JDK_HOME/jre/lib/ext/*.jar
{
"result": [
"org.apache.jasper.servlet.JasperLoader@4fff3bbe",
"ParallelWebappClassLoader\r\n context: ROOT\r\n delegate: false\r\n----------> Parent Classloader:\r\njava.net.URLClassLoader@1218025c\r\n",
"java.net.URLClassLoader@1218025c",
"sun.misc.Launcher$AppClassLoader@42a57993",
"sun.misc.Launcher$ExtClassLoader@6b143ee9"
],
"urlsInfo": {
"ParallelWebappClassLoader\r\n context: ROOT\r\n delegate: false\r\n----------> Parent Classloader:\r\njava.net.URLClassLoader@1218025c\r\n": [
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/classes/",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/devtool-1.0.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/ehcache-3.8.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/FastInfoset-1.2.15.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/fastjson-1.2.55.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/gson-2.8.2.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/guava-16.0.1.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/istack-commons-runtime-3.0.7.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/javax.activation-api-1.2.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/jaxb-api-2.3.1.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/jaxb-runtime-2.3.1.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/jna-4.5.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/leveldb-0.7.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/leveldb-api-0.7.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/log4j-1.2.17.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/logback-classic-1.2.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/logback-core-1.2.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/metrics-core-3.1.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/simpleclient-0.6.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/simpleclient_common-0.6.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/simpleclient_hotspot-0.6.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/simpleclient_servlet-0.6.0.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/slf4j-api-1.7.25.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/stax-ex-1.8.jar",
"file:/Users/dugang/soft/apps/benchmark8010/webapps/ROOT/WEB-INF/lib/txw2-2.3.1.jar"
],
"sun.misc.Launcher$AppClassLoader@42a57993": [
"file:/Users/dugang/soft/apps/benchmark8010/bin/bootstrap.jar",
"file:/Users/dugang/soft/apps/benchmark8010/bin/tomcat-juli.jar"
],
"org.apache.jasper.servlet.JasperLoader@4fff3bbe": [
"file:/Users/dugang/soft/apps/benchmark8010/work/Catalina/localhost/ROOT/"
],
"sun.misc.Launcher$ExtClassLoader@6b143ee9": [
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/cldrdata.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/dnsns.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jaccess.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jfxrt.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/localedata.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/nashorn.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/sunec.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/zipfs.jar",
"file:/System/Library/Java/Extensions/MRJToolkit.jar"
],
"java.net.URLClassLoader@1218025c": [
"file:/Users/dugang/soft/apps/benchmark8010/lib/",
"file:/Users/dugang/soft/apps/benchmark8010/lib/annotations-api.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/catalina-ant.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/catalina-ha.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/catalina-storeconfig.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/catalina-tribes.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/catalina.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/ecj-4.6.3.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/el-api.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/jasper-el.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/jasper.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/jaspic-api.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/jsp-api.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/servlet-api.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-api.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-coyote.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-dbcp.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-i18n-es.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-i18n-fr.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-i18n-ja.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-jdbc.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-jni.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-util-scan.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-util.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/tomcat-websocket.jar",
"file:/Users/dugang/soft/apps/benchmark8010/lib/websocket-api.jar"
]
}
}
eclipse 使用 jetty 插件 获取类加载信息
{
"result": [
"org.apache.jasper.servlet.JasperLoader@64c348a0",
"WebAppClassLoader=benchmark@7ca48474",
"sun.misc.Launcher$AppClassLoader@764c12b6",
"sun.misc.Launcher$ExtClassLoader@17d10166"
],
"urlsInfo": {
"WebAppClassLoader=benchmark@7ca48474": [
"file:/Users/dugang/fun/hellocode/project/benchmark/target/classes/",
"file:/Users/dugang/m2/org/iq80/leveldb/leveldb/0.7/leveldb-0.7.jar",
"file:/Users/dugang/m2/com/google/guava/guava/16.0.1/guava-16.0.1.jar",
"file:/Users/dugang/m2/org/iq80/leveldb/leveldb-api/0.7/leveldb-api-0.7.jar",
"file:/Users/dugang/m2/org/ehcache/ehcache/3.8.0/ehcache-3.8.0.jar",
"file:/Users/dugang/m2/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar",
"file:/Users/dugang/m2/org/glassfish/jaxb/jaxb-runtime/2.3.1/jaxb-runtime-2.3.1.jar",
"file:/Users/dugang/m2/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar",
"file:/Users/dugang/m2/org/glassfish/jaxb/txw2/2.3.1/txw2-2.3.1.jar",
"file:/Users/dugang/m2/com/sun/istack/istack-commons-runtime/3.0.7/istack-commons-runtime-3.0.7.jar",
"file:/Users/dugang/m2/org/jvnet/staxex/stax-ex/1.8/stax-ex-1.8.jar",
"file:/Users/dugang/m2/com/sun/xml/fastinfoset/FastInfoset/1.2.15/FastInfoset-1.2.15.jar",
"file:/Users/dugang/m2/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar",
"file:/Users/dugang/m2/ch/qos/logback/logback-classic/1.2.0/logback-classic-1.2.0.jar",
"file:/Users/dugang/m2/ch/qos/logback/logback-core/1.2.0/logback-core-1.2.0.jar",
"file:/Users/dugang/m2/com/alibaba/fastjson/1.2.55/fastjson-1.2.55.jar",
"file:/Users/dugang/m2/com/google/code/gson/gson/2.8.2/gson-2.8.2.jar",
"file:/Users/dugang/m2/log4j/log4j/1.2.17/log4j-1.2.17.jar",
"file:/Users/dugang/fun/hellocode/project/devtool/target/classes/",
"file:/Users/dugang/m2/io/dropwizard/metrics/metrics-core/3.1.0/metrics-core-3.1.0.jar",
"file:/Users/dugang/m2/io/prometheus/simpleclient/0.6.0/simpleclient-0.6.0.jar",
"file:/Users/dugang/m2/io/prometheus/simpleclient_servlet/0.6.0/simpleclient_servlet-0.6.0.jar",
"file:/Users/dugang/m2/io/prometheus/simpleclient_common/0.6.0/simpleclient_common-0.6.0.jar",
"file:/Users/dugang/m2/io/prometheus/simpleclient_hotspot/0.6.0/simpleclient_hotspot-0.6.0.jar",
"file:/Users/dugang/m2/net/java/dev/jna/jna/4.5.0/jna-4.5.0.jar"
],
"sun.misc.Launcher$AppClassLoader@764c12b6": [
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/eclipse-jetty-starters-common.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/eclipse-jetty-starters-util.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/eclipse-jetty-starters-console.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/eclipse-jetty-starters-embedded.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/javax.servlet.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-server.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-continuation.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-http.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-io.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-util.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-security.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-servlet.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-webapp.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-xml.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-jsp.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/javax.servlet.jsp.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/org.apache.jasper.glassfish.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/javax.servlet.jsp.jstl.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/org.apache.taglibs.standard.glassfish.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/javax.el.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/com.sun.el.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/org.eclipse.jdt.core.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-annotations.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/javax.annotation.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/org.objectweb.asm.jar",
"file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/916/0/.cp/lib/jetty/jetty-plus.jar"
],
"sun.misc.Launcher$ExtClassLoader@17d10166": [
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/cldrdata.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/dnsns.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jaccess.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jfxrt.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/localedata.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/nashorn.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/sunec.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar",
"file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/zipfs.jar",
"file:/System/Library/Java/Extensions/MRJToolkit.jar"
],
"org.apache.jasper.servlet.JasperLoader@64c348a0": [
"file:/private/var/folders/w6/2wzjcqzn4njd5z_df4whdzzr0000gn/T/jetty-0.0.0.0-8080-webapp-_-any-/jsp/"
]
}
}
上一篇
下一篇
slf4j为什么用{}而不是%s
java获取系统信息
mysql MVCC 和 事务隔离级别
tomcat类加载器
java类卸载机制
分布式事务