DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14439>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14439 Can't locate classloader when creating a new LogFactory Summary: Can't locate classloader when creating a new LogFactory Product: Commons Version: unspecified Platform: PC OS/Version: All Status: NEW Severity: Normal Priority: Other Component: Logging AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] 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) { // try general load clazz = Class.forName(factoryClass); } 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) { throw new LogConfigurationException(e); } } -- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>
