Example usage for javax.management ReflectionException toString

List of usage examples for javax.management ReflectionException toString

Introduction

In this page you can find the example usage for javax.management ReflectionException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.mc4j.ems.impl.jmx.connection.bean.attribute.DAttribute.java

/**
 * Updates the local value of this mbean from the server
 * <p/>// w ww.j  a v  a 2  s.co m
 * TODO we should not update to null on failure, but retain the last known
 */
public synchronized Object refresh() {
    loaded = true;
    Object newValue = null;
    try {
        MBeanServer server = bean.getConnectionProvider().getMBeanServer();
        newValue = server.getAttribute(bean.getObjectName(), getName());

    } catch (ReflectionException e) {
        supportedType = false;
        registerFailure(e);
        throw new EmsException("Could not load attribute value " + e.toString(), e);
    } catch (InstanceNotFoundException e) {
        registerFailure(e);
        throw new EmsException(
                "Could not load attribute value, bean instance not found " + bean.getObjectName().toString(),
                e);
    } catch (MBeanException e) {
        registerFailure(e);
        Throwable t = e.getTargetException();
        if (t != null)
            throw new EmsException(
                    "Could not load attribute value, target bean threw exception " + t.getLocalizedMessage(),
                    t);
        else
            throw new EmsException("Could not load attribute value " + e.getLocalizedMessage(), e);
    } catch (AttributeNotFoundException e) {
        registerFailure(e);
        throw new EmsException("Could not load attribute value, attribute [" + getName() + "] not found", e);
    } catch (UndeclaredThrowableException e) {
        if (e.getUndeclaredThrowable() instanceof InvocationTargetException) {
            Throwable t = e.getCause();
            if (t.getCause() instanceof NotSerializableException) {
                supportedType = false;
                registerFailure(t.getCause());
                throw new EmsException("Could not load attribute value " + t.getLocalizedMessage(),
                        t.getCause());
            } else
                throw new EmsException("Could not load attribute value " + t.getLocalizedMessage(), t);
        }
        throw new EmsException("Could not load attribute value " + e.getLocalizedMessage(), e);
    } catch (RuntimeException re) {
        supportedType = false;

        // TODO GH: Figure this one out
        // Getting weblogic.management.NoAccessRuntimeException on wl9
        registerFailure(re);
        throw new EmsException("Could not load attribute value " + re.getLocalizedMessage(), re);
    } catch (NoClassDefFoundError ncdfe) {
        supportedType = false;
        registerFailure(ncdfe);
        throw new EmsException("Could not load attribute value " + ncdfe.getLocalizedMessage(), ncdfe);
    } catch (Throwable t) {
        throw new EmsException("Could not load attribute value " + t.getLocalizedMessage(), t);
    }
    alterValue(newValue);
    return newValue;
}