Search in sources :

Example 56 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project ddf by codice.

the class DataUsage method registerMbean.

private void registerMbean() {
    try {
        objectName = new ObjectName(DataUsage.class.getName() + ":service=datausage");
        mBeanServer = ManagementFactory.getPlatformMBeanServer();
    } catch (MalformedObjectNameException e) {
        LOGGER.error("Unable to create Data Usage Configuration MBean.", e);
    }
    if (mBeanServer == null) {
        return;
    }
    try {
        try {
            mBeanServer.registerMBean(this, objectName);
            LOGGER.info("Registered Data Usage Configuration MBean under object name: {}", objectName.toString());
        } catch (InstanceAlreadyExistsException e) {
            // Try to remove and re-register
            mBeanServer.unregisterMBean(objectName);
            mBeanServer.registerMBean(this, objectName);
            LOGGER.info("Re-registered Data Usage Configuration MBean");
        }
    } catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
        LOGGER.error("Could not register MBean [{}].", objectName.toString(), e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 57 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project ddf by codice.

the class ApplicationServiceBeanTest method testDestroyWhenUnregisterMBeanThrowsInstanceNotFoundException.

/**
     * Tests the {@link ApplicationServiceBean#destroy()} method
     * for the case where an InstanceNotFoundException is thrown by mBeanServer.unregisterMBean(...)
     *
     * @throws Exception
     */
@Test(expected = ApplicationServiceException.class)
public void testDestroyWhenUnregisterMBeanThrowsInstanceNotFoundException() throws Exception {
    ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer);
    doThrow(new InstanceNotFoundException()).when(mBeanServer).unregisterMBean(objectName);
    serviceBean.destroy();
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) Test(org.junit.Test)

Example 58 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project tomcat by apache.

the class SlowQueryReportJmx method deregisterJmx.

protected void deregisterJmx() {
    try {
        if (mbeans.remove(poolName) != null) {
            ObjectName oname = getObjectName(getClass(), poolName);
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(oname);
        }
    } catch (MBeanRegistrationException e) {
        log.debug("Jmx deregistration failed.", e);
    } catch (InstanceNotFoundException e) {
        log.debug("Jmx deregistration failed.", e);
    } catch (MalformedObjectNameException e) {
        log.warn("Jmx deregistration failed.", e);
    } catch (RuntimeOperationsException e) {
        log.warn("Jmx deregistration failed.", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 59 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project tomcat by apache.

the class DataSource method unregisterJmx.

/**
     *
     */
protected void unregisterJmx() {
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        mbs.unregisterMBean(oname);
    } catch (InstanceNotFoundException ignore) {
    // NOOP
    } catch (Exception e) {
        log.error("Unable to unregister JDBC pool with JMX", e);
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanServer(javax.management.MBeanServer)

Example 60 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project jersey by jersey.

the class MBeansTest method checkResourceMBean.

private void checkResourceMBean(String name) throws MalformedObjectNameException {
    final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    final ObjectName objectName = new ObjectName("org.glassfish.jersey:type=myApplication,subType=Uris,resource=\"" + name + "\"");
    ObjectInstance mbean = null;
    try {
        mbean = mBeanServer.getObjectInstance(objectName);
    } catch (InstanceNotFoundException e) {
        Assert.fail("Resource MBean name '" + name + "' not found.");
    }
    assertNotNull(mbean);
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectInstance(javax.management.ObjectInstance) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

InstanceNotFoundException (javax.management.InstanceNotFoundException)102 ObjectName (javax.management.ObjectName)59 ReflectionException (javax.management.ReflectionException)44 MBeanException (javax.management.MBeanException)32 MalformedObjectNameException (javax.management.MalformedObjectNameException)28 MBeanRegistrationException (javax.management.MBeanRegistrationException)25 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)19 MBeanServer (javax.management.MBeanServer)17 IOException (java.io.IOException)16 AttributeNotFoundException (javax.management.AttributeNotFoundException)16 Attribute (javax.management.Attribute)15 IntrospectionException (javax.management.IntrospectionException)14 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)14 AttributeList (javax.management.AttributeList)12 ObjectInstance (javax.management.ObjectInstance)12 MBeanInfo (javax.management.MBeanInfo)11 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)10 RuntimeOperationsException (javax.management.RuntimeOperationsException)9 ArrayList (java.util.ArrayList)7 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)7