Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
None
-
None
-
None
-
Operating System: All
Platform: PC
-
14439
Description
When running WebSphere 5.0 Early Adopters using the Sysdeo Tomcat plugin in
debug mode I discovered that the LogFactory can't locate a classloader to
create new Factories. A call to LogFactory.class.getClassLoader()
returns 'null'. As of the SDK documentation this may be tha case if the
bootstrap has loaded the class. I thus suggest the following code for the
newFactory method taken from v1.0.2 of the common logging API:
/**
- Return a new instance of the specified <code>LogFactory</code>
- implementation class, loaded by the specified class loader.
- If that fails, try the class loader used to load this
- (abstract) LogFactory.
* - @param factoryClass Fully qualified name of the <code>LogFactory</code>
- implementation class
- @param classLoader ClassLoader from which to load this class
* - @exception LogConfigurationException if a suitable instance
- cannot be created
*/
protected static LogFactory newFactory(String factoryClass,
ClassLoader classLoader)
throws LogConfigurationException
{
try {
if (classLoader == null)
classLoader = LogFactory.class.getClassLoader();
Class clazz = null;
try {
// #FIX: RBA
// may be null in case the classloader is the bootstrap
loader
if(classLoader == null)
else
{ // first the thread class loader clazz = classLoader.loadClass(factoryClass); } } catch (ClassNotFoundException ex) {
// if this failed (i.e. no implementation is
// found in the webapp), try the caller's loader
// if we haven't already...
if (classLoader != LogFactory.class.getClassLoader()) {
classLoader = LogFactory.class.getClassLoader();
if(classLoader == null)
{ // try general load clazz = Class.forName(factoryClass); }else
{ clazz = classLoader.loadClass(factoryClass); } }
}
LogFactory factory = (LogFactory)clazz.newInstance();
return factory;
} catch (Exception e)
}