Example usage for javax.management InstanceAlreadyExistsException getMessage

List of usage examples for javax.management InstanceAlreadyExistsException getMessage

Introduction

In this page you can find the example usage for javax.management InstanceAlreadyExistsException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.cyberway.issue.crawler.admin.CrawlJob.java

public void setupForCrawlStart() throws InitializationException {
    try {//from   w ww. ja v  a 2s . c om
        this.controller = setupCrawlController();
        // Register as listener to get job finished notice.
        this.controller.addCrawlStatusListener(this);
        this.controller.initialize(getSettingsHandler());
        // Set the crawl job this MBeanCrawlController needs to worry about.
        ((MBeanCrawlController) this.controller).setCrawlJob(this);
        // Create our mbean description and register our crawljob.
        this.openMBeanInfo = buildMBeanInfo();
        try {
            Heritrix.registerMBean(this, getJmxJobName(), CRAWLJOB_JMXMBEAN_TYPE);
        } catch (InstanceAlreadyExistsException e) {
            throw new InitializationException(e);
        } catch (MBeanRegistrationException e) {
            throw new InitializationException(e);
        } catch (NotCompliantMBeanException e) {
            throw new InitializationException(e);
        }
    } catch (InitializationException e) {
        // Can't load current job since it is misconfigured.
        setStatus(CrawlJob.STATUS_MISCONFIGURED);
        setErrorMessage("A fatal InitializationException occured when " + "loading job:\n" + e.getMessage());
        // Log to stdout so its seen in logs as well as in UI.
        e.printStackTrace();
        this.controller = null;
        throw e;
    }
    setStatus(CrawlJob.STATUS_RUNNING);
    setRunning(true);
}

From source file:org.opendaylight.controller.config.threadpool.fixed.FixedThreadPoolConfigBeanTest.java

@Test
public void testNegative()
        throws ConflictingVersionException, ValidationException, InstanceAlreadyExistsException {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();

    createFixed(transaction, nameInstance, 5, nameInstance);
    transaction.commit();//from   w  w  w .j  a v a  2s .  c o m

    transaction = configRegistryClient.createTransaction();
    try {
        createFixed(transaction, nameInstance, 0, nameInstance);
        fail();
    } catch (InstanceAlreadyExistsException e) {
        assertThat(e.getMessage(), containsString(
                "There is an instance registered with name ModuleIdentifier{factoryName='threadpool-fixed', instanceName='fixedInstance'}"));
    }
}

From source file:org.springframework.jmx.export.MBeanExporter.java

/**
 * Actually registers the MBean with the server. The behavior when encountering
 * an existing MBean can be configured using the {@link #setRegistrationBehavior(int)}
 * and {@link #setRegistrationBehaviorName(String)} methods.
 *///from   ww  w.  j  a  va  2 s  . com
private ObjectName doRegister(Object mbean, ObjectName objectName) throws JMException {
    ObjectInstance registeredBean = null;
    try {
        registeredBean = this.server.registerMBean(mbean, objectName);
    } catch (InstanceAlreadyExistsException ex) {
        if (this.registrationBehavior == REGISTRATION_IGNORE_EXISTING) {
            if (logger.isDebugEnabled()) {
                logger.debug("Ignoring existing MBean at [" + objectName + "]");
            }
        } else if (this.registrationBehavior == REGISTRATION_REPLACE_EXISTING) {
            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("Replacing existing MBean at [" + objectName + "]");
                }
                this.server.unregisterMBean(objectName);
                registeredBean = this.server.registerMBean(mbean, objectName);
            } catch (InstanceNotFoundException ex2) {
                throw new IllegalStateException(
                        "Unable to replace existing MBean at [" + objectName + "]: " + ex.getMessage());
            }
        } else {
            throw ex;
        }
    }
    // Track registration and notify listeners.
    ObjectName actualObjectName = (registeredBean != null ? registeredBean.getObjectName() : null);
    if (actualObjectName == null) {
        actualObjectName = objectName;
    }
    return actualObjectName;
}

From source file:org.wso2.carbon.ndatasource.rdbms.RDBMSDataSource.java

private void registerMBean() {
    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    String mBean = "";
    try {/*  w w w .  j ava2s .  c  om*/
        if (DataSourceUtils.getCurrentDataSourceId() == null) {
            if (log.isDebugEnabled()) {
                log.debug("The current dataSource id is not set");
            }
            return;
        }
        String[] dataSourceId = DataSourceUtils.getCurrentDataSourceId().split(":");
        mBean = dataSourceId[1] + "," + dataSourceId[0];
        ObjectName objectName = new ObjectName(mBean + ":type=DataSource");
        mBeanServer.registerMBean(this.dataSource.createPool().getJmxPool(), objectName);
    } catch (InstanceAlreadyExistsException e) {
        //ignore as the mbean for the same datasource name is already exist
    } catch (MalformedObjectNameException e) {
        log.error("Error while registering the MBean for dataSource '" + mBean + " " + e.getMessage(), e);
    } catch (NotCompliantMBeanException e) {
        log.error("Error while registering the MBean for dataSource '" + mBean + " " + e.getMessage(), e);
    } catch (SQLException e) {
        log.error("Error while registering the MBean for dataSource '" + mBean + " " + e.getMessage(), e);
    } catch (MBeanRegistrationException e) {
        log.error("Error while registering the MBean for dataSource '" + mBean + " " + e.getMessage(), e);
    }
}