// so we can use this class' classloader
cls = getClass().getClassLoader().loadClass(className);
}
catch (ClassNotFoundException x)
{
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Cannot load Throwable class " + className, x);
}
if (cls == null) return fault;
Object exception = null;
if (message != null)
{
try
{
// Try to find the suitable constructor
Constructor ctor = cls.getConstructor(new Class[]{String.class});
exception = ctor.newInstance(new Object[]{message});
}
catch (Throwable x)
{
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Cannot find constructor " + className + "(String message)", x);
}
}
if (exception == null)
{
try
{
exception = cls.newInstance();
}
catch (Throwable x)
{
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Cannot find constructor " + className + "()", x);
}
}
// Handle JMX exceptions with special case constructors
if (MBeanException.class.getName().equals(className))
{
exception = new MBeanException(null, message);
}
else if (RuntimeMBeanException.class.getName().equals(className))
{
exception = new RuntimeMBeanException(null, message);
}
if (!(exception instanceof Throwable))
{
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Could not recreate exception thrown on server side: " + className);
return fault;
}
return (Throwable)exception;
}