You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mike Noordermeer <mi...@normi.net> on 2011/02/24 16:04:46 UTC

[configuration] Basepath not set with DefaultConfigurationBuilder/ConfigurationBuilderProvider

Hi,

I've an issue with the DefaultConfigurationBuilder, and I'm wondering if 
I'm doing something wrong or if it's a bug.

I've the following structure:

/WEB-INF/config/defs/def-1.xml
/WEB-INF/config/defs/def-2.xml
/WEB-INF/config/config1.properties

I use a DefaultConfigurationBuilder, with the following contents in the 
def-1.xml:

<configuration>
   <override>
   	<properties fileName="../config1.properties"/>
   	<configuration fileName="def-2.xml"/>
   </override>
</configuration>

I use this code:

DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
builder.setURL(ctx.getResource("/WEB-INF/config/defs/def-1.xml"));
Configuration c = builder.getConfiguration(true);

This gives an exception:

Caused by: org.apache.commons.configuration.ConfigurationException: 
Cannot locate configuration source def-2.xml
	at 
org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:217)
[...]

Seems to be that AbstractFileConfiguration.basePath is not set by the 
DefaultConfigurationBuilder.ConfigurationBuilderProvider, while it is 
set by DefaultConfigurationBuilder.FileConfigurationProvider (in 
initBeanInstance(Object, BeanDeclaration)).

Is this a bug, or am I doing something wrong and is it not possible/is 
there an other way to include files which are not in the current working 
dir in a DefaultConfigurationBuilder XML.

tia

-- 
Regards,

Mike Noordermeer
mike@normi.net

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


Re: [configuration] Basepath not set with DefaultConfigurationBuilder/ConfigurationBuilderProvider

Posted by Oliver Heger <ol...@oliver-heger.de>.
Hi Mike,

Am 24.02.2011 16:04, schrieb Mike Noordermeer:
> Hi,
>
> I've an issue with the DefaultConfigurationBuilder, and I'm wondering if
> I'm doing something wrong or if it's a bug.
>
> I've the following structure:
>
> /WEB-INF/config/defs/def-1.xml
> /WEB-INF/config/defs/def-2.xml
> /WEB-INF/config/config1.properties
>
> I use a DefaultConfigurationBuilder, with the following contents in the
> def-1.xml:
>
> <configuration>
> <override>
> <properties fileName="../config1.properties"/>
> <configuration fileName="def-2.xml"/>
> </override>
> </configuration>
>
> I use this code:
>
> DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
> builder.setURL(ctx.getResource("/WEB-INF/config/defs/def-1.xml"));
> Configuration c = builder.getConfiguration(true);
>
> This gives an exception:
>
> Caused by: org.apache.commons.configuration.ConfigurationException:
> Cannot locate configuration source def-2.xml
> at
> org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:217)
>
> [...]
>
> Seems to be that AbstractFileConfiguration.basePath is not set by the
> DefaultConfigurationBuilder.ConfigurationBuilderProvider, while it is
> set by DefaultConfigurationBuilder.FileConfigurationProvider (in
> initBeanInstance(Object, BeanDeclaration)).
>
> Is this a bug, or am I doing something wrong and is it not possible/is
> there an other way to include files which are not in the current working
> dir in a DefaultConfigurationBuilder XML.
>
> tia
>

yes I think you are right: ConfigurationBuilderProvider does not set the 
base path which is most likely the source of your problem. Could you 
please open a ticket in our bug tracking system [1]?

Thanks for the report and your analysis.

Oliver

[1] http://commons.apache.org/configuration/issue-tracking.html

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