javax.management.NotCompliantMBeanException Java Examples

The following examples show how to use javax.management.NotCompliantMBeanException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManagementFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers a DynamicMBean.
 */
private static void addDynamicMBean(final MBeanServer mbs,
                                    final DynamicMBean dmbean,
                                    final ObjectName on) {
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws InstanceAlreadyExistsException,
                                     MBeanRegistrationException,
                                     NotCompliantMBeanException {
                mbs.registerMBean(dmbean, on);
                return null;
            }
        });
    } catch (PrivilegedActionException e) {
        throw new RuntimeException(e.getException());
    }
}
 
Example #2
Source File: RoleInfo.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param roleName  name of the role
 * @param mbeanClassName  name of the class of MBean(s) expected to
 * be referenced in corresponding role.  If an MBean <em>M</em> is in
 * this role, then the MBean server must return true for
 * {@link MBeanServer#isInstanceOf isInstanceOf(M, mbeanClassName)}.
 *
 * <P>IsReadable and IsWritable defaulted to true.
 * <P>Minimum and maximum degrees defaulted to 1.
 * <P>Description of role defaulted to null.
 *
 * @exception IllegalArgumentException  if null parameter
 * @exception ClassNotFoundException As of JMX 1.2, this exception
 * can no longer be thrown.  It is retained in the declaration of
 * this class for compatibility with existing code.
 * @exception NotCompliantMBeanException As of JMX 1.2, this
 * exception can no longer be thrown.  It is retained in the
 * declaration of this class for compatibility with existing code.
  */
public RoleInfo(String roleName,
                String mbeanClassName)
throws IllegalArgumentException,
       ClassNotFoundException,
       NotCompliantMBeanException {

    try {
        init(roleName,
             mbeanClassName,
             true,
             true,
             1,
             1,
             null);
    } catch (InvalidRoleInfoException exc) {
        // OK : Can never happen as the minimum
        //      degree equals the maximum degree.
    }

    return;
}
 
Example #3
Source File: MBeanServerAccessController.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object params[], String signature[])
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className,
                                                     params,
                                                     signature);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name,
                                            params, signature);
    }
}
 
Example #4
Source File: ManagementFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers a DynamicMBean.
 */
private static void addDynamicMBean(final MBeanServer mbs,
                                    final DynamicMBean dmbean,
                                    final ObjectName on) {
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws InstanceAlreadyExistsException,
                                     MBeanRegistrationException,
                                     NotCompliantMBeanException {
                mbs.registerMBean(dmbean, on);
                return null;
            }
        });
    } catch (PrivilegedActionException e) {
        throw new RuntimeException(e.getException());
    }
}
 
Example #5
Source File: AbstractBucketStatistics.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * @param aTitle
 *            A title for console pretty printing
 * @param pkg
 *            A package name for this statistics, e.g. tlc2.tool.liveness
 *            for stats are from classes in the liveness package.
 * @param name
 *            The (class) name of the source of the statistics.
 */
public AbstractBucketStatistics(final String aTitle, final String pkg, final String name) {
	this(aTitle);
	try {
		//TODO unregister somehow
		new BucketStatisticsMXWrapper(this, name, pkg);
	} catch (NotCompliantMBeanException e) {
		// not expected to happen would cause JMX to be broken, hence just log and
		// continue
		MP.printWarning(
				EC.GENERAL,
				"Failed to create MBean wrapper for BucketStatistics. No statistics/metrics will be avaiable.",
				e);
		TLCStandardMBean.getNullTLCStandardMBean();
	}
}
 
Example #6
Source File: ManagementFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers a DynamicMBean.
 */
private static void addDynamicMBean(final MBeanServer mbs,
                                    final DynamicMBean dmbean,
                                    final ObjectName on) {
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws InstanceAlreadyExistsException,
                                     MBeanRegistrationException,
                                     NotCompliantMBeanException {
                mbs.registerMBean(dmbean, on);
                return null;
            }
        });
    } catch (PrivilegedActionException e) {
        throw new RuntimeException(e.getException());
    }
}
 
Example #7
Source File: DefaultMBeanServerInterceptor.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private static String getNewMBeanClassName(Object mbeanToRegister)
        throws NotCompliantMBeanException {
    if (mbeanToRegister instanceof DynamicMBean) {
        DynamicMBean mbean = (DynamicMBean) mbeanToRegister;
        final String name;
        try {
            name = mbean.getMBeanInfo().getClassName();
        } catch (Exception e) {
            // Includes case where getMBeanInfo() returns null
            NotCompliantMBeanException ncmbe =
                new NotCompliantMBeanException("Bad getMBeanInfo()");
            ncmbe.initCause(e);
            throw ncmbe;
        }
        if (name == null) {
            final String msg = "MBeanInfo has null class name";
            throw new NotCompliantMBeanException(msg);
        }
        return name;
    } else
        return mbeanToRegister.getClass().getName();
}
 
Example #8
Source File: MBeanServerAccessController.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className, ObjectName name)
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name);
    }
}
 
Example #9
Source File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private static String getNewMBeanClassName(Object mbeanToRegister)
        throws NotCompliantMBeanException {
    if (mbeanToRegister instanceof DynamicMBean) {
        DynamicMBean mbean = (DynamicMBean) mbeanToRegister;
        final String name;
        try {
            name = mbean.getMBeanInfo().getClassName();
        } catch (Exception e) {
            // Includes case where getMBeanInfo() returns null
            NotCompliantMBeanException ncmbe =
                new NotCompliantMBeanException("Bad getMBeanInfo()");
            ncmbe.initCause(e);
            throw ncmbe;
        }
        if (name == null) {
            final String msg = "MBeanInfo has null class name";
            throw new NotCompliantMBeanException(msg);
        }
        return name;
    } else
        return mbeanToRegister.getClass().getName();
}
 
Example #10
Source File: MBeanFallbackTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testPrivate(Class<?> iface, Object bean) throws Exception {
    try {
        System.out.println("Registering a private MBean " +
                            iface.getName() + " ...");

        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Compliant");

        mbs.registerMBean(bean, on);
        success("Registered a private MBean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("MBean not registered");
        } else {
            throw e;
        }
    }
}
 
Example #11
Source File: JMXProxyFallbackTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void testPrivate(Class<?> iface) throws Exception {
    try {
        System.out.println("Creating a proxy for private M(X)Bean " +
                            iface.getName() + " ...");

        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Proxy");

        JMX.newMBeanProxy(mbs, on, iface);
        success("Created a proxy for private M(X)Bean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("Proxy not created");
        } else {
            throw e;
        }
    }
}
 
Example #12
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static String getNewMBeanClassName(Object mbeanToRegister)
        throws NotCompliantMBeanException {
    if (mbeanToRegister instanceof DynamicMBean) {
        DynamicMBean mbean = (DynamicMBean) mbeanToRegister;
        final String name;
        try {
            name = mbean.getMBeanInfo().getClassName();
        } catch (Exception e) {
            // Includes case where getMBeanInfo() returns null
            NotCompliantMBeanException ncmbe =
                new NotCompliantMBeanException("Bad getMBeanInfo()");
            ncmbe.initCause(e);
            throw ncmbe;
        }
        if (name == null) {
            final String msg = "MBeanInfo has null class name";
            throw new NotCompliantMBeanException(msg);
        }
        return name;
    } else
        return mbeanToRegister.getClass().getName();
}
 
Example #13
Source File: MBeanTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void testCompliant(Class<?> iface, Object bean) throws Exception {
    try {
        System.out.println("Registering a compliant MBean " +
                            iface.getName() + " ...");

        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Compliant");

        mbs.registerMBean(bean, on);
        success("Registered a compliant MBean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("MBean not registered");
        } else {
            throw e;
        }
    }
}
 
Example #14
Source File: MBeanTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static void testCompliant(Class<?> iface, Object bean) throws Exception {
    try {
        System.out.println("Registering a compliant MBean " +
                            iface.getName() + " ...");

        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Compliant");

        mbs.registerMBean(bean, on);
        success("Registered a compliant MBean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("MBean not registered");
        } else {
            throw e;
        }
    }
}
 
Example #15
Source File: MBeanFallbackTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void testPrivate(Class<?> iface, Object bean) throws Exception {
    try {
        System.out.println("Registering a private MBean " +
                            iface.getName() + " ...");

        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Compliant");

        mbs.registerMBean(bean, on);
        success("Registered a private MBean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("MBean not registered");
        } else {
            throw e;
        }
    }
}
 
Example #16
Source File: MBeanTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testNonCompliant(Class<?> iface, Object bean) throws Exception {
    try {
        System.out.println("Registering a non-compliant MBean " +
                            iface.getName() + " ...");

        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=NonCompliant");

        mbs.registerMBean(bean, on);

        fail("Registered a non-compliant MBean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            success("MBean not registered");
        } else {
            throw e;
        }
    }
}
 
Example #17
Source File: ManagementFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers a DynamicMBean.
 */
private static void addDynamicMBean(final MBeanServer mbs,
                                    final DynamicMBean dmbean,
                                    final ObjectName on) {
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws InstanceAlreadyExistsException,
                                     MBeanRegistrationException,
                                     NotCompliantMBeanException {
                mbs.registerMBean(dmbean, on);
                return null;
            }
        });
    } catch (PrivilegedActionException e) {
        throw new RuntimeException(e.getException());
    }
}
 
Example #18
Source File: MBeanTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testNonCompliant(Class<?> iface, Object bean) throws Exception {
    try {
        System.out.println("Registering a non-compliant MBean " +
                            iface.getName() + " ...");

        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=NonCompliant");

        mbs.registerMBean(bean, on);

        fail("Registered a non-compliant MBean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            success("MBean not registered");
        } else {
            throw e;
        }
    }
}
 
Example #19
Source File: MBeanServerAccessController.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className, ObjectName name)
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name);
    }
}
 
Example #20
Source File: MBeanSupport.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
<T> MBeanSupport(T resource, Class<T> mbeanInterfaceType)
        throws NotCompliantMBeanException {
    if (mbeanInterfaceType == null)
        throw new NotCompliantMBeanException("Null MBean interface");
    if (!mbeanInterfaceType.isInstance(resource)) {
        final String msg =
            "Resource class " + resource.getClass().getName() +
            " is not an instance of " + mbeanInterfaceType.getName();
        throw new NotCompliantMBeanException(msg);
    }
    ReflectUtil.checkPackageAccess(mbeanInterfaceType);
    this.resource = resource;
    MBeanIntrospector<M> introspector = getMBeanIntrospector();
    this.perInterface = introspector.getPerInterface(mbeanInterfaceType);
    this.mbeanInfo = introspector.getMBeanInfo(resource, perInterface);
}
 
Example #21
Source File: DefaultMBeanServerInterceptor.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance registerMBean(Object object, ObjectName name)
    throws InstanceAlreadyExistsException, MBeanRegistrationException,
    NotCompliantMBeanException  {

    // ------------------------------
    // ------------------------------
    Class<?> theClass = object.getClass();

    Introspector.checkCompliance(theClass);

    final String infoClassName = getNewMBeanClassName(object);

    checkMBeanPermission(infoClassName, null, name, "registerMBean");
    checkMBeanTrustPermission(theClass);

    return registerObject(infoClassName, object, name);
}
 
Example #22
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException  {

    try {
        return createMBean(className, name, null, true,
                           params, signature);
    } catch (InstanceNotFoundException e) {
        /* Can only happen if loaderName doesn't exist, but we just
           passed null, so we shouldn't get this exception.  */
        throw EnvHelp.initCause(
            new IllegalArgumentException("Unexpected exception: " + e), e);
    }
}
 
Example #23
Source File: DefaultMBeanServerInterceptor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance registerMBean(Object object, ObjectName name)
    throws InstanceAlreadyExistsException, MBeanRegistrationException,
    NotCompliantMBeanException  {

    // ------------------------------
    // ------------------------------
    Class<?> theClass = object.getClass();

    Introspector.checkCompliance(theClass);

    final String infoClassName = getNewMBeanClassName(object);

    checkMBeanPermission(infoClassName, null, name, "registerMBean");
    checkMBeanTrustPermission(theClass);

    return registerObject(infoClassName, object, name);
}
 
Example #24
Source File: MXBeanProxy.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public MXBeanProxy(Class<?> mxbeanInterface) {

        if (mxbeanInterface == null)
            throw new IllegalArgumentException("Null parameter");

        final MBeanAnalyzer<ConvertingMethod> analyzer;
        try {
            analyzer =
                MXBeanIntrospector.getInstance().getAnalyzer(mxbeanInterface);
        } catch (NotCompliantMBeanException e) {
            throw new IllegalArgumentException(e);
        }
        analyzer.visit(new Visitor());
    }
 
Example #25
Source File: OldMBeanServerTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(
        String className, ObjectName name, ObjectName loaderName,
        Object[] params, String[] signature)
throws ReflectionException, InstanceAlreadyExistsException,
        MBeanRegistrationException, MBeanException,
        NotCompliantMBeanException, InstanceNotFoundException {
    Object mbean = instantiate(className, loaderName, params, signature);
    return registerMBean(mbean, name);
}
 
Example #26
Source File: RMIConnector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(String className,
        ObjectName name,
        ObjectName loaderName,
        Object params[],
        String signature[])
        throws ReflectionException,
        InstanceAlreadyExistsException,
        MBeanRegistrationException,
        MBeanException,
        NotCompliantMBeanException,
        InstanceNotFoundException,
        IOException {
    if (logger.debugOn()) logger.debug(
            "createMBean(String,ObjectName,ObjectName,Object[],String[])",
            "className=" + className + ", name=" + name + ", loaderName="
            + loaderName + ", signature=" + strings(signature));

    final MarshalledObject<Object[]> sParams =
            new MarshalledObject<Object[]>(params);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.createMBean(className,
                name,
                loaderName,
                sParams,
                signature,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.createMBean(className,
                name,
                loaderName,
                sParams,
                signature,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #27
Source File: MXBeanFallbackTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testPrivateMXBean(String type, Object bean) throws Exception {
    System.out.println(type + " MXBean test...");
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    ObjectName on = new ObjectName("test:type=" + type);
    try {
        mbs.registerMBean(bean, on);
        success("Private MXBean registered");
    } catch (NotCompliantMBeanException e) {
        failure("Failed to register the private MXBean - " +
                 bean.getClass().getInterfaces()[0].getName());
    }
}
 
Example #28
Source File: OldMBeanServerTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(
        String className, ObjectName name, ObjectName loaderName)
throws ReflectionException, InstanceAlreadyExistsException,
        MBeanRegistrationException, MBeanException,
        NotCompliantMBeanException, InstanceNotFoundException {
    return createMBean(className, name, loaderName, null, null);
}
 
Example #29
Source File: TddlMBeanServer.java    From tddl5 with Apache License 2.0 5 votes vote down vote up
private synchronized void realRegisterMBean(Object o, ObjectName objectName) throws InstanceAlreadyExistsException,
                                                                            MBeanRegistrationException,
                                                                            NotCompliantMBeanException {
    ObjectName old = beanNameHolder.putIfAbsent(objectName.getCanonicalName(), objectName);
    if (old == null) {
        mbs.registerMBean(o, objectName);
        return;
    }
    log.error("same mbean try to register to BeanServer, reject! bean id is : " + objectName.getCanonicalName());
}
 
Example #30
Source File: ExceptionDiagnosisTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void testMXBeans(Object mbean, Type... expectedTypes)
        throws Exception {
    try {
        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName name = new ObjectName("a:b=c");
        mbs.registerMBean(mbean, name);
        fail("No exception from registerMBean for " + mbean);
    } catch (NotCompliantMBeanException e) {
        checkExceptionChain("MBean " + mbean, e, expectedTypes);
    }
}