commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: [Configuration] Problem with combining two xml-files
Date Thu, 26 Jun 2008 20:02:16 GMT
Michael Post schrieb:
> Hello,
> 
> i use the current version (1.5) of commons configuration for my project
> with commons-beanutils-1.7.0.jar, commons-chain-1.2.jar,
> commons-codec-1.3.jar, commons-collections-3.2.1.jar,
> commons-digester-1.8.jar, commons-jxpath-1.2.jar, commons-lang-2.4.jar
> und commons-logging-1.1.1.jar.
> 
> I want to read combine the two xml configuration files to one and later
> i want to read some properties of it.
> 
> Like the tutorial on
> http://commons.apache.org/configuration/userguide/howto_combinedconfiguration.html
> i programmed my small plain Java application (ConfigTest.java) in which
> i read both configurations like the tutorial. Some lines later i read
> some properties of the configuration but all values are null.
> 
> I can not understand why / what is wrong.
> 
> Thanks for supporting me,
> 
> Michael
> 

The code for creating the combined configuration seems to be alright. I 
assume the problem lies in your usage of the getProperties() method, 
which probably does not what you expect. Have a look at the Javadocs for 
the Configuration interface.

I recommend that you try to read simple properties first using 
getString() or one of the other simple get() methods. I am not sure what 
you want to achieve with getProperties(). Maybe the configurationAt() 
method goes in this direction?

For debugging combined configurations you can use the following trick: 
Copy the content of the combined configuration into an XMLConfiguration:

CombinedConfiguration cc = ...
XMLConfiguration conf = new XMLConfiguration(cc);

Then the XMLConfiguration can be saved. The resulting XML file shows the 
structure of the combined configuration.

HTH
Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message