commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rusty Wright <>
Subject [CONFIGURATION] need help with DefaultConfigurationBuilder and CombinedConfiguration
Date Fri, 19 Dec 2008 01:59:13 GMT
I'm using Spring to autowire things together; in my Spring test-applicationContext.xml I have

    <bean id="configurationBuilder" class="org.apache.commons.configuration.DefaultConfigurationBuilder">
         <property name="fileName" value="test-config-xml.xml" />

In test-config-xml.xml I have

    <?xml version="1.0" encoding="ISO-8859-1" ?>



And ftp.xml contains

    <?xml version="1.0" encoding="ISO-8859-1" ?>





The ${} placeholders are replaced by maven when I run my tests.  The email.xml file contains
similar entries.

In my class that uses the DefaultConfigurationBuilder, it's injected by Spring in its constructor:

    public FtpEdt(final DefaultConfigurationBuilder configBuilder)
            throws ConfigurationException {

        final CombinedConfiguration combinedConfig = configBuilder.getConfiguration(true);

        final Configuration config = combinedConfig.getConfiguration("ftp");

        this.server = config.getString("server");

        if (this.server == null)
            throw (new IllegalStateException("server not set"));

The problem is when the Email class's constructor is called, which looks very similar, it
blows up on the configBuilder.getConfiguration(true); with

Caused by: org.apache.commons.configuration.ConfigurationRuntimeException: A configuration
with the name 'ftp' already exists in this combined configuration!
        at org.apache.commons.configuration.CombinedConfiguration.addConfiguration(
        at org.apache.commons.configuration.DefaultConfigurationBuilder.initCombinedConfiguration(
        at org.apache.commons.configuration.DefaultConfigurationBuilder.getConfiguration(
        at<init>( [classes/:na]

So I guess I don't understand how to use the CombinedConfiguration and the DefaultConfigurationBuilder;
can someone give me some hints for how to do this?


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

View raw message