If I understand you correctly, you don't get an exception, but you cannot access your properties, i.e. your configuration is empty.

I would guess that the problem lies in your configuration definition file PLConfig.xml. Make sure that it has the correct format. The root element must be named <configuration>. Below that there can be elements that load configuration sources like <properties> or <xml>.

A source for working examples can be the unit tests. The test class for ConfigurationFactory loads multiple files from different sources.

HTH
Oliver

Charles Griswold wrote:

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");
}
factory.setConfigurationFileName(name);
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: "+eio.getMessage());
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
factory.setConfigurationFileName(configURL.toString());


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to