commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Griswold <>
Subject Commons Configuration Problem
Date Wed, 02 Mar 2005 15:59:59 GMT
I am trying to set up the Commons Configration facility.  It seems like 
no matter what I do
I can't get it to read the configuration file. What is particuarly 
confusing is that I had it working after a fashion and now it doesn't
My code looks like:
 private void getConfig(String name) throws Exception {
        try {
            ConfigurationFactory factory = new ConfigurationFactory();
            File ft = new File(name);
            if (!ft.exists() ) {
                logger.fatal("PlanLogix - Error Configuration file: 
"+name+" Missing. Execution halted");
            String a = factory.getBasePath();                           
//test code
            String b = factory.getConfigurationFileName();     //test code
            config = factory.getConfiguration();
        } catch (ConfigurationException eio) {
            logger.fatal("PlanLogix - Error Reading Configuration file: 
"+name+" Execution halted");
            logger.fatal("PlanLogix - Error: "+eio.getCause()+" Message: 
            throw eio;
The 'name' is c:\PLConfig.xml    The value from 
factory.getConfigurationFileName()   is PLConfig
The value from  actory.getBasePath() is   "."
I've also tried this with the same code used in the example in the 
Commons 'Setting up Configuration Factory'

ConfigurationFactory factory = new ConfigurationFactory();
URL configURL = new File("config.xml").toURL();				<- config.xml was c:\PLConfig.xml

This did nothing either.  When the getConfiguration method is called, I get a CPU spike but
when I try to extract 
values from the configuration there is nothing there.

I also tried using setBasePath(path) to no avail, just null pointer exceptions.
I've tried every variety of calsses and methods but nothing.

Can anyone offer advice or a known working example?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message