in src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java [1149:1205]
private ClassLoader getBaseClassLoader() throws LogConfigurationException {
final ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.class);
if (!useTCCL) {
return thisClassLoader;
}
final ClassLoader contextClassLoader = getContextClassLoaderInternal();
final ClassLoader baseClassLoader = getLowestClassLoader(
contextClassLoader, thisClassLoader);
if (baseClassLoader == null) {
// The two classloaders are not part of a parent child relationship.
// In some classloading setups (e.g. JBoss with its
// UnifiedLoaderRepository) this can still work, so if user hasn't
// forbidden it, just return the contextClassLoader.
if (!allowFlawedContext) {
throw new LogConfigurationException("Bad classloader hierarchy; LogFactoryImpl was loaded via" +
" a classloader that is not related to the current context" +
" classloader.");
}
if (isDiagnosticsEnabled()) {
logDiagnostic("[WARNING] the context classloader is not part of a" +
" parent-child relationship with the classloader that" +
" loaded LogFactoryImpl.");
}
// If contextClassLoader were null, getLowestClassLoader() would
// have returned thisClassLoader. The fact we are here means
// contextClassLoader is not null, so we can just return it.
return contextClassLoader;
}
if (baseClassLoader != contextClassLoader) {
// We really should just use the contextClassLoader as the starting
// point for scanning for log adapter classes. However it is expected
// that there are a number of broken systems out there which create
// custom classloaders but fail to set the context classloader so
// we handle those flawed systems anyway.
if (!allowFlawedContext) {
throw new LogConfigurationException(
"Bad classloader hierarchy; LogFactoryImpl was loaded via" +
" a classloader that is not related to the current context" +
" classloader.");
}
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Warning: the context classloader is an ancestor of the" +
" classloader that loaded LogFactoryImpl; it should be" +
" the same or a descendant. The application using" +
" commons-logging should ensure the context classloader" +
" is used correctly.");
}
}
return baseClassLoader;
}