ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader(); if (logFactoryClassLoader == null) { logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader"); } else { logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader); implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass); if (implementsLogFactory) { logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " implements LogFactory but was loaded by an incompatible classloader."); } else { logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " does not implement LogFactory."); logDiagnostic("[CUSTOM LOG FACTORY] SecurityException thrown whilst trying to determine whether " + "the compatibility was caused by a classloader conflict: " + e.getMessage()); } catch (LinkageError e) { logDiagnostic("[CUSTOM LOG FACTORY] LinkageError thrown whilst trying to determine whether " + "the compatibility was caused by a classloader conflict: " + e.getMessage()); } catch (ClassNotFoundException e) { logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by classloader which loaded " + "the custom LogFactory implementation. Is the custom factory in the right classloader?");
logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir")); logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path")); } catch (SecurityException ex) { logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths."); } catch (SecurityException ex) { logDiagnostic("[ENV] Security forbids determining the classloader for " + className); return; logDiagnostic("[ENV] Class " + className + " was loaded via classloader " + objectId(classLoader)); logHierarchy("[ENV] Ancestry of classloader which loaded " + className + " is ", classLoader);
} catch (SecurityException ex) { if (isDiagnosticsEnabled()) { logDiagnostic("Unable to get classloader for class '" + clazz + "' due to security restrictions - " + ex.getMessage());
if (classLoader != null) { final String classLoaderString = classLoader.toString(); logDiagnostic(prefix + objectId(classLoader) + " == '" + classLoaderString + "'"); systemClassLoader = ClassLoader.getSystemClassLoader(); } catch (SecurityException ex) { logDiagnostic(prefix + "Security forbids determining the system classloader."); return; logDiagnostic(buf.toString());
ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader(); if (logFactoryClassLoader == null) { logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader"); } else { logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader); implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass); if (implementsLogFactory) { logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " implements LogFactory but was loaded by an incompatible classloader."); } else { logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " does not implement LogFactory."); logDiagnostic("[CUSTOM LOG FACTORY] SecurityException thrown whilst trying to determine whether " + "the compatibility was caused by a classloader conflict: " + e.getMessage()); logDiagnostic("[CUSTOM LOG FACTORY] LinkageError thrown whilst trying to determine whether " + "the compatibility was caused by a classloader conflict: " + e.getMessage()); logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by classloader which loaded the " + "custom LogFactory implementation. Is the custom factory in the right classloader?");
/** * Release any internal references to previously created {@link LogFactory} * instances, after calling the instance method <code>release()</code> on * each of them. This is useful in environments like servlet containers, * which implement application reloading by throwing away a ClassLoader. * Dangling references to objects in that class loader would prevent * garbage collection. */ public static void releaseAll() { if (isDiagnosticsEnabled()) { logDiagnostic("Releasing factory for all classloaders."); } // factories is not final and could be replaced in this block. final Hashtable factories = LogFactory.factories; synchronized (factories) { final Enumeration elements = factories.elements(); while (elements.hasMoreElements()) { LogFactory element = (LogFactory) elements.nextElement(); element.release(); } factories.clear(); if (nullClassLoaderFactory != null) { nullClassLoaderFactory.release(); nullClassLoaderFactory = null; } } }
logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir")); logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path")); } catch(SecurityException ex) { logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths."); } catch(SecurityException ex) { logDiagnostic( "[ENV] Security forbids determining the classloader for " + className); return; logDiagnostic( "[ENV] Class " + className + " was loaded via classloader " + objectId(classLoader));
} catch(SecurityException ex) { if (isDiagnosticsEnabled()) { logDiagnostic( "Unable to get classloader for class '" + clazz + "' due to security restrictions - " + ex.getMessage());
logDiagnostic("[LOOKUP] Properties file found at '" + url + "'" + " with priority " + priority); logDiagnostic("[LOOKUP] Properties file at '" + url + "'" + " with priority " + newPriority + " overrides file at '" + propsUrl + "'" + } else { if (isDiagnosticsEnabled()) { logDiagnostic("[LOOKUP] Properties file at '" + url + "'" + " with priority " + newPriority + " does not override file at '" + propsUrl + "'" + logDiagnostic("SecurityException thrown while trying to find/read config files."); logDiagnostic("[LOOKUP] No properties file of name '" + fileName + "' found."); } else { logDiagnostic("[LOOKUP] Properties file of name '" + fileName + "' found at '" + propsUrl + '"');
logDiagnostic("[ERROR] LogFactory: Load of custom hashtable failed"); } else {
if (classLoader != null) { final String classLoaderString = classLoader.toString(); logDiagnostic(prefix + objectId(classLoader) + " == '" + classLoaderString + "'"); systemClassLoader = ClassLoader.getSystemClassLoader(); } catch(SecurityException ex) { logDiagnostic( prefix + "Security forbids determining the system classloader."); return; logDiagnostic(buf.toString());
logDiagnostic("[ERROR] LogFactory: Load of custom hashtable failed"); } else {
/** * Release any internal references to previously created {@link LogFactory} * instances, after calling the instance method <code>release()</code> on * each of them. This is useful in environments like servlet containers, * which implement application reloading by throwing away a ClassLoader. * Dangling references to objects in that class loader would prevent * garbage collection. */ public static void releaseAll() { if (isDiagnosticsEnabled()) { logDiagnostic("Releasing factory for all classloaders."); } synchronized (factories) { Enumeration elements = factories.elements(); while (elements.hasMoreElements()) { LogFactory element = (LogFactory) elements.nextElement(); element.release(); } factories.clear(); if (nullClassLoaderFactory != null) { nullClassLoaderFactory.release(); nullClassLoaderFactory = null; } } }
/** * Release any internal references to previously created {@link LogFactory} * instances that have been associated with the specified class loader * (if any), after calling the instance method <code>release()</code> on * each of them. * * @param classLoader ClassLoader for which to release the LogFactory */ public static void release(ClassLoader classLoader) { if (isDiagnosticsEnabled()) { logDiagnostic("Releasing factory for classloader " + objectId(classLoader)); } // factories is not final and could be replaced in this block. final Hashtable factories = LogFactory.factories; synchronized (factories) { if (classLoader == null) { if (nullClassLoaderFactory != null) { nullClassLoaderFactory.release(); nullClassLoaderFactory = null; } } else { final LogFactory factory = (LogFactory) factories.get(classLoader); if (factory != null) { factory.release(); factories.remove(classLoader); } } } }
logDiagnostic( "[LOOKUP] Properties file found at '" + url + "'" + " with priority " + priority); logDiagnostic( "[LOOKUP] Properties file at '" + url + "'" + " with priority " + newPriority } else { if (isDiagnosticsEnabled()) { logDiagnostic( "[LOOKUP] Properties file at '" + url + "'" + " with priority " + newPriority logDiagnostic("SecurityException thrown while trying to find/read config files."); logDiagnostic( "[LOOKUP] No properties file of name '" + fileName + "' found."); } else { logDiagnostic( "[LOOKUP] Properties file of name '" + fileName + "' found at '" + propsUrl + '"');
if (LogFactory.class.isAssignableFrom(logFactoryClass)) { if (isDiagnosticsEnabled()) { logDiagnostic("Loaded class " + logFactoryClass.getName() + " from classloader " + objectId(classLoader)); logDiagnostic("Factory class " + logFactoryClass.getName() + " loaded from classloader " + objectId(logFactoryClass.getClassLoader()) + " does not extend '" + LogFactory.class.getName() + logDiagnostic("Unable to locate any class called '" + factoryClass + "' via classloader " + objectId(classLoader)); logDiagnostic("Class '" + factoryClass + "' cannot be loaded" + " via classloader " + objectId(classLoader) + " - it depends on some other class that cannot be found."); logDiagnostic(msg.toString()); logDiagnostic("Unable to load factory class via classloader " + objectId(classLoader) + " - trying the classloader associated with this LogFactory."); logDiagnostic("Unable to create LogFactory instance.");
LogConfigurationException ex = (LogConfigurationException) result; if (isDiagnosticsEnabled()) { logDiagnostic("An error occurred while loading the factory class:" + ex.getMessage()); logDiagnostic("Created object " + objectId(result) + " to manage classloader " + objectId(contextClassLoader));
/** * Release any internal references to previously created {@link LogFactory} * instances that have been associated with the specified class loader * (if any), after calling the instance method <code>release()</code> on * each of them. * * @param classLoader ClassLoader for which to release the LogFactory */ public static void release(ClassLoader classLoader) { if (isDiagnosticsEnabled()) { logDiagnostic("Releasing factory for classloader " + objectId(classLoader)); } synchronized (factories) { if (classLoader == null) { if (nullClassLoaderFactory != null) { nullClassLoaderFactory.release(); nullClassLoaderFactory = null; } } else { LogFactory factory = (LogFactory) factories.get(classLoader); if (factory != null) { factory.release(); factories.remove(classLoader); } } } }
logDiagnostic("Context classloader is null."); logDiagnostic( "[LOOKUP] LogFactory implementation requested for the first time for context classloader " + objectId(contextClassLoader)); logDiagnostic("[LOOKUP] Looking for system property [" + FACTORY_PROPERTY + "] to define the LogFactory subclass to use..."); if (factoryClass != null) { if (isDiagnosticsEnabled()) { logDiagnostic("[LOOKUP] Creating an instance of LogFactory class '" + factoryClass + "' as specified by system property " + FACTORY_PROPERTY); } else { if (isDiagnosticsEnabled()) { logDiagnostic("[LOOKUP] No system property [" + FACTORY_PROPERTY + "] defined."); logDiagnostic("[LOOKUP] A security exception occurred while trying to create an" + " instance of the custom factory class" + ": [" + trim(e.getMessage()) + "]. Trying alternative implementations..."); logDiagnostic("[LOOKUP] An exception occurred while trying to create an" + " instance of the custom factory class" + ": [" + trim(e.getMessage()) + logDiagnostic("[LOOKUP] Looking for a resource file of name [" + SERVICE_ID + "] to define the LogFactory subclass to use...");
LogConfigurationException ex = (LogConfigurationException) result; if (isDiagnosticsEnabled()) { logDiagnostic( "An error occurred while loading the factory class:" + ex.getMessage()); logDiagnostic( "Created object " + objectId(result) + " to manage classloader " + objectId(contextClassLoader));