Example usage for org.apache.commons.configuration ConfigurationException getMessage

List of usage examples for org.apache.commons.configuration ConfigurationException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.configuration ConfigurationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:it.grid.storm.config.ConfigReader.java

public ConfigReader(String configurationPathname, int refresh) {

    if (configurationPathname != null) {
        if (refresh < 0)
            refresh = 0;//w  w  w . ja v a2s.c  o  m
        this.refresh = refresh;
        this.configurationPathname = configurationPathname;
        log.info("Configuration file {}. Refresh rate: {} seconds", configurationPathname, refresh);

        try {
            FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
            strategy.setRefreshDelay(refresh);
            PropertiesConfiguration properties = new PropertiesConfiguration(configurationPathname);
            log.debug("Configuration properties:");
            String key;
            for (Iterator<?> i = properties.getKeys(); i.hasNext();) {
                key = (String) i.next();
                log.debug("{} = {}", key, properties.getProperty(key).toString());
            }
            properties.setReloadingStrategy(strategy);
            this.c = new CompositeConfiguration();
            ((CompositeConfiguration) this.c).addConfiguration(properties);
            log.info("Configuration read successfully.");
        } catch (ConfigurationException e) {
            this.c = makeEmptyConfiguration();
            log.error("Configuration parsing error: {}", e.getMessage(), e);
        }
    } else {
        throw new NullPointerException("Null configuration pathname.");
    }
}

From source file:it.geosolutions.opensdi2.configurations.dao.PropertiesDAO.java

private PropertiesConfiguration loadConfigurationInstance(File configFile)
        throws OSDIConfigurationNotFoundException {
    PropertiesConfiguration config = null;
    try {//from   www  .j av a  2s. c o m
        config = new PropertiesConfiguration(configFile);
    } catch (ConfigurationException e) {
        throw new OSDIConfigurationNotFoundException(e.getMessage());
    }
    return config;
}

From source file:com.github.blacklocus.rdsecho.EchoCfg.java

EchoCfg(String propertiesFilename) {
    this.cfg = new CompositeConfiguration();
    this.cfg.addConfiguration(new SystemConfiguration());
    try {//from   w  w  w  .  java 2s  .  co  m
        this.cfg.addConfiguration(new PropertiesConfiguration(propertiesFilename));
        LOG.info("Reading configuration from {}", propertiesFilename);

    } catch (ConfigurationException e) {
        LOG.info("{} will not be read because {}", propertiesFilename, e.getMessage());
    }
    validate();
}

From source file:com.qmetry.qaf.automation.util.PropertyUtil.java

public void storePropertyFile(File f) {
    try {/*from   w w  w .  java2  s  .c  o m*/
        save(f);
    } catch (ConfigurationException e) {
        logger.error(e.getMessage());
    }
}

From source file:hu.ppke.itk.nlpg.purepos.cli.PurePos.java

@Override
public void run() {
    try {/*from   w  w w  .j av  a 2s .c om*/
        Configuration conf;
        if (options.configFile != null) {
            ConfigurationReader reader = new ConfigurationReader();
            conf = reader.read(new File(options.configFile));
            Util.LEMMA_MAPPER = new StringMapper(conf.getLemmaMappings());
        } else {
            conf = new Configuration();
        }
        Util.CONFIGURATION = conf;

        if (options.command.equals(TRAIN_OPT)) {
            train(options.encoding, options.modelName, options.fromFile, options.tagOrder,
                    options.emissionOrder, options.suffixLength, options.rareFreq);
        } else if (options.command.equals(TAG_OPT)) {
            tag(options.encoding, options.modelName, options.fromFile, options.morphology, options.noStemming,
                    options.maxGuessed, options.maxResultsNumber, options.beamTheta, options.useBeamSearch,
                    options.toFile);
        }
    } catch (ConfigurationException e) {
        System.err.println("Malformed configuration file: " + e.getMessage());
    } catch (ParsingException e) {
        System.err.println(e.getWrappedException().getMessage());
    } catch (Exception e) {
        // System.err.println(e.getMessage());
        e.printStackTrace();

        System.exit(-1);
    }
}

From source file:com.lehman.ic9.io.config.java

/**
 * Loads the configuration from the provided file name.
 * @param FileName is a String with the config file to load.
 * @throws ic9exception if something goes wrong.
 *//*  w ww.  j a va  2 s.  c om*/
public void load(String FileName) throws ic9exception {
    try {
        this.config = new PropertiesConfiguration(FileName);
    } catch (ConfigurationException e) {
        throw new ic9exception("config.load(): ConfigurationException: " + e.getMessage());
    }
}

From source file:com.lehman.ic9.io.config.java

/**
 * Saves the current config to a file with the provided file name.
 * @param FileName is a String with the file name to save the config to.
 * @throws ic9exception if something goes wrong.
 *//*w w w.  j a v a  2 s.c  om*/
public void save(String FileName) throws ic9exception {
    try {
        this.config.save(FileName);
    } catch (ConfigurationException e) {
        throw new ic9exception("config.save(): ConfigurationException: " + e.getMessage());
    }
}

From source file:com.vangent.hieos.pixnotifierutil.config.PIXNotifierConfig.java

/**
 * /*w  w  w  .  j  a v  a2s.com*/
 * @throws PIXNotifierUtilException
 */
private void loadConfiguration() throws PIXNotifierUtilException {
    String empiConfigDir = XConfig.getConfigLocation(XConfig.ConfigItem.EMPI_DIR);
    String configLocation = empiConfigDir + "/" + PIXNotifierConfig.CONFIG_FILE_NAME;
    try {
        XMLConfiguration xmlConfig = new XMLConfiguration(configLocation);

        // Load cross reference consumers.
        this.loadCrossReferenceConsumers(xmlConfig);

    } catch (ConfigurationException ex) {
        throw new PIXNotifierUtilException("PIXNotifierConfig: Could not load configuration from "
                + configLocation + " " + ex.getMessage());
    }
}

From source file:com.qmetry.qaf.automation.util.PropertyUtil.java

private boolean loadFile(File file) {
    try {/*from w w w .j ava2  s.c om*/
        if (file.getName().endsWith("xml") || file.getName().contains(".xml.")) {
            super.load(new FileInputStream(file));
            XMLConfiguration xmlConfiguration = new XMLConfiguration(file);
            copy(xmlConfiguration);
            xmlConfiguration.clear();
        } else {
            PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
            propertiesConfiguration
                    .setEncoding(getString(ApplicationProperties.LOCALE_CHAR_ENCODING.key, "UTF-8"));
            propertiesConfiguration.load(new FileInputStream(file));
            copy(propertiesConfiguration);
            propertiesConfiguration.clear();
            // super.load(new FileInputStream(file));
        }
        return true;
    } catch (ConfigurationException e) {
        logger.error(e.getMessage());
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage());
    }

    return false;
}

From source file:eu.matejkormuth.ts3bot.Bot.java

/**
 * Shutdowns all services and disconnects from ServerQuery.
 *///w  ww .ja  v  a2  s. co m
public void shutdown() {
    // Disable reading of commands.
    this.consoleReader.disable();

    this.logger.info("Shutting down...");
    try {
        if (this.configuration.getBoolean("config.useExternal", true)) {
            this.configuration.setFile(new File("/bot.properties"));
            this.configuration.save();
            this.logger.info("Configuration saved!");
        }
    } catch (ConfigurationException e) {
        this.logger.error("Couldn't save configuration: {}", e.getMessage());
    }
    this.logger.info("Shutting down services...");
    // Shutdown services.
    for (Service service : this.services) {
        try {
            this.eventBus.unregister(service);
            service.disable();
        } catch (Exception e) {
            this.logger.error("Can't disable service! Problem: {}", e.getMessage());
            this.logger.error(e.toString());
        }
    }
    this.logger.info("Disconnecting...");
    // Close connection.
    this.queryConnection.disconnect();
    // Bye!
    this.logger.info("Thanks for using!");
    this.logger.info("Bye!");
}