commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gavin Eadie <ga...@umich.edu>
Subject Re: [Commons Configuratin]: Suppress exceptions about missing optional property files?
Date Tue, 08 Apr 2008 00:02:49 GMT
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
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message