commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mortagne <>
Subject Re: [configuration] Creating a properties file
Date Wed, 30 Aug 2017 08:56:50 GMT
Here is what I currently do:

            PropertiesBuilderParameters parameters = new
            if (file.exists()) {
                new Parameters().properties().setFile(file);

            FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
            PropertiesConfiguration properties = builder.getConfiguration();

            properties.setProperty("property", "value");


but I find it more complex than it should.

IMO the file handler should not care if the file exist or not by
default (empty PropertiesConfiguration as in 1.x if it does not exist)
and only fail if asked to in the parameters of the builder. At the
very least it should be possible to have some way to tell the builder
to not care about not existing file.

On Wed, Aug 30, 2017 at 10:37 AM, Thomas Mortagne
<> wrote:
> Hi,
> I trying to move from Commons Configuration 1.x to 2.1.1 and I cannot
> figure out how to do something that used to be obvious: creating a
> properties file that does not yet exist on the file system.
> In 1.x all I had to do is create a PropertiesConfiguration with a
> File, set a few properties and then save.
> In 2.1.1 I cannot find how to configure the build for it to accept a
> path to a file that does not exist, I always end up with:
> org.apache.commons.configuration2.ex.ConfigurationException: Could not
> locate:[,basePath=/media/data/projets/xwiki/src/git/xwiki-commons/xwiki-commons-core/xwiki-commons-job/target/test/jobs/status,sourceURL=,encoding=ISO-8859-1,fileSystem=<null>,locationStrategy=<null>]
>     at
>     at
>     at
> and from what I see in FileHandler sources it not really configurable.
> So did I missed something or am I really supposed to create an empty
> file before using the builder ?
> Thanks,
> --
> Thomas


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

View raw message