java - Why doesn't activating the delegating classloader in tomcat change the apparent hierarchy of classloading at runtime? -


in tomcat, can reverse default ordering of classloading hierarchy setting <loader delegate="true"/> in context element.

however, if try recursively dumping contents of classloaders, ordering same:

static {     classloader classloader = simpleservlet.class.getclassloader();     url[] urls;     if (classloader != null) {         urls = ((urlclassloader) classloader).geturls();         logger.info("simpleservlet.class: " + arrays.aslist(urls));         while(classloader.getparent() != null) {             classloader = classloader.getparent();             urls = ((urlclassloader) classloader).geturls();             logger.info("parent: " + arrays.aslist(urls));         }     } else {         logger.info("simpleservlet.class classloader null");     }      if (classloader != null) {         classloader = classloader.getsystemclassloader();         urls = ((urlclassloader) classloader).geturls();         logger.info("system: " + arrays.aslist(urls));         while(classloader.getparent() != null) {             classloader = classloader.getparent();             urls = ((urlclassloader) classloader).geturls();             logger.info("parent: " + arrays.aslist(urls));         }     } else {         logger.info("system classloader null");     }      if (classloader != null) {         classloader = thread.currentthread().getcontextclassloader();         urls = ((urlclassloader) classloader).geturls();         logger.info("context: " + arrays.aslist(urls));         while(classloader.getparent() != null) {             classloader = classloader.getparent();             urls = ((urlclassloader) classloader).geturls();             logger.info("parent: " + arrays.aslist(urls));         }     } else {         logger.info("context classloader null");     } } 

results in (simplifed readability):

[rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - simpleservlet.class: [file:.../libexec/webapps/root/web-inf/classes/, file:.../libexec/webapps/root/web-inf/lib/guava-14.0.1.jar, file:.../libexec/webapps/root/web-inf/lib/slf4j-api-1.7.25.jar, file:.../libexec/webapps/root/web-inf/lib/slf4j-simple-1.7.25.jar] [rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - parent: [file:.../libexec/lib/, file:.../libexec/lib/annotations-api.jar, file:.../libexec/lib/catalina-ant.jar, file:.../libexec/lib/catalina-ha.jar, file:.../libexec/lib/catalina-storeconfig.jar, file:.../libexec/lib/catalina-tribes.jar, file:.../libexec/lib/catalina.jar, file:.../libexec/lib/commons-logging-1.2.jar, file:.../libexec/lib/ecj-4.5.1.jar, file:.../libexec/lib/el-api.jar, file:.../libexec/lib/hadoop-common-2.7.1.jar, file:.../libexec/lib/hbase-common-1.1.2.jar, file:.../libexec/lib/jasper-el.jar, file:.../libexec/lib/jasper.jar, file:.../libexec/lib/jaspic-api.jar, file:.../libexec/lib/jsp-api.jar, file:.../libexec/lib/servlet-api.jar, file:.../libexec/lib/tomcat-api.jar, file:.../libexec/lib/tomcat-coyote.jar, file:.../libexec/lib/tomcat-dbcp.jar, file:.../libexec/lib/tomcat-i18n-es.jar, file:.../libexec/lib/tomcat-i18n-fr.jar, file:.../libexec/lib/tomcat-i18n-ja.jar, file:.../libexec/lib/tomcat-jdbc.jar, file:.../libexec/lib/tomcat-jni.jar, file:.../libexec/lib/tomcat-util-scan.jar, file:.../libexec/lib/tomcat-util.jar, file:.../libexec/lib/tomcat-websocket.jar, file:.../libexec/lib/websocket-api.jar] [rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - parent: [file:.../libexec/bin/bootstrap.jar, file:.../libexec/bin/tomcat-juli.jar] [rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - parent: [file:.../jre/lib/ext/cldrdata.jar, file:.../jre/lib/ext/dnsns.jar, file:.../jre/lib/ext/jaccess.jar, file:.../jre/lib/ext/jfxrt.jar, file:.../jre/lib/ext/localedata.jar, file:.../jre/lib/ext/nashorn.jar, file:.../jre/lib/ext/sunec.jar, file:.../jre/lib/ext/sunjce_provider.jar, file:.../jre/lib/ext/sunpkcs11.jar, file:.../jre/lib/ext/zipfs.jar, file:.../applescriptengine.jar, file:.../dns_sd.jar, file:.../j3daudio.jar, file:.../j3dcore.jar, file:.../j3dutils.jar, file:.../jai_codec.jar, file:.../jai_core.jar, file:.../libapplescriptengine.jnilib, file:.../libj3d.jnilib, file:.../libj3daudio.jnilib, file:.../libj3dutils.jnilib, file:.../libmlib_jai.jnilib, file:.../mlibwrapper_jai.jar, file:.../mrjtoolkit.jar, file:.../vecmath.jar, file:/usr/lib/java/libjdns_sd.jnilib]  [rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - system: [file:.../libexec/bin/bootstrap.jar, file:.../libexec/bin/tomcat-juli.jar] [rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - parent: [file:.../jre/lib/ext/cldrdata.jar, file:.../jre/lib/ext/dnsns.jar, file:.../jre/lib/ext/jaccess.jar, file:.../jre/lib/ext/jfxrt.jar, file:.../jre/lib/ext/localedata.jar, file:.../jre/lib/ext/nashorn.jar, file:.../jre/lib/ext/sunec.jar, file:.../jre/lib/ext/sunjce_provider.jar, file:.../jre/lib/ext/sunpkcs11.jar, file:.../jre/lib/ext/zipfs.jar, file:.../applescriptengine.jar, file:.../dns_sd.jar, file:.../j3daudio.jar, file:.../j3dcore.jar, file:.../j3dutils.jar, file:.../jai_codec.jar, file:.../jai_core.jar, file:.../libapplescriptengine.jnilib, file:.../libj3d.jnilib, file:.../libj3daudio.jnilib, file:.../libj3dutils.jnilib, file:.../libmlib_jai.jnilib, file:.../mlibwrapper_jai.jar, file:.../mrjtoolkit.jar, file:.../vecmath.jar, file:/usr/lib/java/libjdns_sd.jnilib]  [rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - context: [file:.../libexec/webapps/root/web-inf/classes/, file:.../libexec/webapps/root/web-inf/lib/guava-14.0.1.jar, file:.../libexec/webapps/root/web-inf/lib/slf4j-api-1.7.25.jar, file:.../libexec/webapps/root/web-inf/lib/slf4j-simple-1.7.25.jar] [rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - parent: [file:.../libexec/lib/, file:.../libexec/lib/annotations-api.jar, file:.../libexec/lib/catalina-ant.jar, file:.../libexec/lib/catalina-ha.jar, file:.../libexec/lib/catalina-storeconfig.jar, file:.../libexec/lib/catalina-tribes.jar, file:.../libexec/lib/catalina.jar, file:.../libexec/lib/commons-logging-1.2.jar, file:.../libexec/lib/ecj-4.5.1.jar, file:.../libexec/lib/el-api.jar, file:.../libexec/lib/hadoop-common-2.7.1.jar, file:.../libexec/lib/hbase-common-1.1.2.jar, file:.../libexec/lib/jasper-el.jar, file:.../libexec/lib/jasper.jar, file:.../libexec/lib/jaspic-api.jar, file:.../libexec/lib/jsp-api.jar, file:.../libexec/lib/servlet-api.jar, file:.../libexec/lib/tomcat-api.jar, file:.../libexec/lib/tomcat-coyote.jar, file:.../libexec/lib/tomcat-dbcp.jar, file:.../libexec/lib/tomcat-i18n-es.jar, file:.../libexec/lib/tomcat-i18n-fr.jar, file:.../libexec/lib/tomcat-i18n-ja.jar, file:.../libexec/lib/tomcat-jdbc.jar, file:.../libexec/lib/tomcat-jni.jar, file:.../libexec/lib/tomcat-util-scan.jar, file:.../libexec/lib/tomcat-util.jar, file:.../libexec/lib/tomcat-websocket.jar, file:.../libexec/lib/websocket-api.jar] [rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - parent: [file:.../libexec/bin/bootstrap.jar, file:.../libexec/bin/tomcat-juli.jar] [rmi tcp connection(2)-127.0.0.1] info com.example.simpleservlet - parent: [file:.../jre/lib/ext/cldrdata.jar, file:.../jre/lib/ext/dnsns.jar, file:.../jre/lib/ext/jaccess.jar, file:.../jre/lib/ext/jfxrt.jar, file:.../jre/lib/ext/localedata.jar, file:.../jre/lib/ext/nashorn.jar, file:.../jre/lib/ext/sunec.jar, file:.../jre/lib/ext/sunjce_provider.jar, file:.../jre/lib/ext/sunpkcs11.jar, file:.../jre/lib/ext/zipfs.jar, file:.../applescriptengine.jar, file:.../dns_sd.jar, file:.../j3daudio.jar, file:.../j3dcore.jar, file:.../j3dutils.jar, file:.../jai_codec.jar, file:.../jai_core.jar, file:.../libapplescriptengine.jnilib, file:.../libj3d.jnilib, file:.../libj3daudio.jnilib, file:.../libj3dutils.jnilib, file:.../libmlib_jai.jnilib, file:.../mlibwrapper_jai.jar, file:.../mrjtoolkit.jar, file:.../vecmath.jar, file:/usr/lib/java/libjdns_sd.jnilib] 

whether delegate true or false.

i have expected see order of class , context loaders correspond order in docs:

delegate=false:

bootstrap classes of jvm /web-inf/classes of web application /web-inf/lib/*.jar of web application system class loader classes common class loader classes 

delegate=true:

bootstrap classes of jvm system class loader classes common class loader classes /web-inf/classes of web application /web-inf/lib/*.jar of web application 

instead is:

/web-inf/classes of web application /web-inf/lib/*.jar of web application common class loader classes system class loader classes bootstrap classes of jvm 

which different both listings in docs. what's going on here? hierarchy of classloaders in memory not map onto tomcat's search hierarchy in way?


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -