Gavin Eadie schrieb:
On Apr 6, 2008, at 4:42 PM, Emmanuel Bourg wrote:
Try using ConfigurationBuilder instead of ConfigurationFactory, you shouldn't have this exception.

I get it with the following:

   try {
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
     builder.setURL(configURL);
     this.clear();
this.addConfiguration((AbstractConfiguration)builder.getConfiguration());
   }

when reading:

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

  <configuration>
    <properties fileName="config.properties" />
    <properties fileName="deploy.properties" optional="true" />
           <xml fileName="config.xml" />
  </configuration>

and "deploy.properties" is not available to be read. I just assumed this was a warning I had to put up with.

  DEBUG ation.ConfigurationUtils : ConfigurationUtils.locate(): base is
    file:[...]/build/MiniSandbox.woa/Contents/Resources/,
    name is deploy.properties
   WARN aultConfigurationBuilder : Internal error
      org.apache.commons.configuration.ConfigurationException:
        Cannot locate configuration source deploy.properties at
        org.apache.commons.configuration.AbstractFileConfiguration. \
        load(AbstractFileConfiguration.java:215)

I stepped my way through the code in question and don't understand what's happening. The isOptional() method's return value is true at line 975 of DefaultConfigurationBuilder,
so it ought to not throw the exception -- but it does.

    catch (Exception ex)
    {
      // If this is an optional configuration, ignore the exception
       if (!decl.isOptional())
       {
          throw ex;
       }
       else
       {

All the source I explored is from the sources.jar that is a part of config 1.5

If a configuration marked as optional cannot be loaded, DefaultConfigurationBuilder notifies all registered error listeners (i.e. an error event is fired). Per default, an error listener is registered that only logs the causing exception.

To disable this behavior you can call clearErrorListeners() on the DefaultConfigurationBuilder instance.

Oliver

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

Reply via email to