You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Lukas Bradley <lu...@somnia.com> on 2005/07/27 17:13:36 UTC

[Configuration] FileChangedReloadingStrategy Not Working?

Is there anything in the following code block that would prevent the 
FileChangedReloadingStrategy from functioning correctly?  It is declared 
  just after member variables within the class itself.  The properties 
load correctly utilizing getString(), getFloat(), etc.  However, they do 
not reload after file changes and subsequent requests.

    /** Name of the bundle containing the messages. */
    private static String                  BUNDLE_NAME     = 
"p2p_common_MySettings.properties";

    /** Resource from which the messages are obtained. */
    private static PropertiesConfiguration RESOURCE_BUNDLE = null;
    static
    {
       try
       {
          FileChangedReloadingStrategy strat = new 
FileChangedReloadingStrategy() ;
          // Reload file every 1 minute
          strat.setRefreshDelay(1 * 60 * 1000) ;
          RESOURCE_BUNDLE = new PropertiesConfiguration(BUNDLE_NAME);
          RESOURCE_BUNDLE.setReloadingStrategy(strat) ;
       }
       catch (ConfigurationException e)
       {
          Admin.log(MySettings.class, "Loading props", e);
       }

    }

Note: I have read the bug 
http://issues.apache.org/bugzilla/show_bug.cgi?id=35529 in BugZilla, and 
agree with those comments.  However, I am requesting updates from 
getString() and the file is still not reloading.


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


Jelly Script: Test for empty folder?

Posted by Michael Owen <mi...@hotmail.com>.
Hi,

How do can test if a folder is empty with jelly script?

Mike



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


Re: [Configuration] FileChangedReloadingStrategy Not Working?

Posted by Lukas Bradley <lu...@somnia.com>.
Lukas Bradley wrote:
> Is there anything in the following code block that would prevent the 
> FileChangedReloadingStrategy from functioning correctly?  It is declared 
>  just after member variables within the class itself.  The properties 
> load correctly utilizing getString(), getFloat(), etc.  However, they do 
> not reload after file changes and subsequent requests.

I'm concerned with the logging during the reload attempts.  In 
ConfigurationUtils, a Commons Logger is being used to display output. 
However, on line 637 of AbstractFileConfiguration, where the reload() is 
to take place, a stack trace is send to standard error instead of to a 
Commons Logger.

If an error occurs, is the Commons Configuration logging setup ensuring 
that all standard error output is being redirected to Commons Logging?




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


Re: [Configuration] FileChangedReloadingStrategy Not Working?

Posted by Lukas Bradley <lu...@somnia.com>.
Christian Hufgard wrote:
> as far as i remember, there are allready some bugs concerning this
> problem in bugzilla. I had the same problem and solved it, by manually
> calling config.setBasePath(String path) with the propertyfile's
> basepath. Think there are also some other fixes in Bugzilla posted.

Sorry for the extra traffic-- I didn't find those bugs.

Thanks for the post.  I'll give it a shot.


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


Re[2]: [Configuration] FileChangedReloadingStrategy Not Working?

Posted by Christian Hufgard <ch...@gmx.de>.
Hi Lukas,

as far as i remember, there are allready some bugs concerning this
problem in bugzilla. I had the same problem and solved it, by manually
calling config.setBasePath(String path) with the propertyfile's
basepath. Think there are also some other fixes in Bugzilla posted.


Christian

Wednesday, July 27, 2005, 5:58:13 PM, you wrote:

>> Is there anything in the following code block that would prevent the
>> FileChangedReloadingStrategy from functioning correctly?  It is declared
>>  just after member variables within the class itself.  The properties
>> load correctly utilizing getString(), getFloat(), etc.  However, they do
>> not reload after file changes and subsequent requests.

> I don't think the following (from the Commons Configuration Properties
> files documentation) would ever work with version 1.1:

>     PropertiesConfiguration config = new 
> PropertiesConfiguration("usergui.properties");
>     config.setReloadingStrategy(new FileChangedReloadingStrategy());

> It appears that properties files loaded using String filename 
> constructor of PropertiesConfiguration (assumed to be resources in the
> classpath) are verfied using a relative path from the working directory
> within FileChangedReloadingStrategy.hasChanged().  Unless your resources
> are stored in your working directory, it probably won't find them.

> Please add the following code to line 111 in the hasChanged() method of
>   FileChangedReloadingStrategy for more information.
 
> org.apache.commons.logging.LogFactory.getLog(FileChangedReloadingStrategy.class).debug("file
> doesn't exist " + configuration.getFile().getAbsolutePath()) ;

> FYI -- I'm storing my Properties files within 
> tomcat/webapps/ROOT/WEB-INF/classes.  They are loading correctly, but
> not re-loading at all.

> Please let me know if *I'm* doing something wrong, or have misunderstood
> how to utilize this functionality.  If I don't hear anything in the next
> 6 hours or so, I'll add an item to Bugzilla.


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





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


Re: [Configuration] FileChangedReloadingStrategy Not Working?

Posted by Oliver Heger <he...@med.uni-marburg.de>.
Lukas Bradley wrote:
>> Hi Lukas, what version of Commons Configuration did you use ? The 1.1 
>> or a nightly build ?
> 
> 
> 1.1
> 
Then you should give the nightly builds a try. Some problems have been 
fixed in the meantime. Especially the reloading strategy now always uses 
the source URL (i.e. the URL from which the configuration file was 
loaded) to monitor the file.

Oliver

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


Re: [Configuration] FileChangedReloadingStrategy Not Working?

Posted by Lukas Bradley <lu...@somnia.com>.
> Hi Lukas, what version of Commons Configuration did you use ? The 1.1 or 
> a nightly build ?

1.1


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


Re: [Configuration] FileChangedReloadingStrategy Not Working?

Posted by Emmanuel Bourg <eb...@apache.org>.
Hi Lukas, what version of Commons Configuration did you use ? The 1.1 or 
a nightly build ?

Emmanuel Bourg


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


Re: [Configuration] FileChangedReloadingStrategy Not Working?

Posted by Lukas Bradley <lu...@somnia.com>.
> Is there anything in the following code block that would prevent the 
> FileChangedReloadingStrategy from functioning correctly?  It is declared 
>  just after member variables within the class itself.  The properties 
> load correctly utilizing getString(), getFloat(), etc.  However, they do 
> not reload after file changes and subsequent requests.

I don't think the following (from the Commons Configuration Properties 
files documentation) would ever work with version 1.1:

    PropertiesConfiguration config = new 
PropertiesConfiguration("usergui.properties");
    config.setReloadingStrategy(new FileChangedReloadingStrategy());

It appears that properties files loaded using String filename 
constructor of PropertiesConfiguration (assumed to be resources in the 
classpath) are verfied using a relative path from the working directory 
within FileChangedReloadingStrategy.hasChanged().  Unless your resources 
are stored in your working directory, it probably won't find them.

Please add the following code to line 111 in the hasChanged() method of 
  FileChangedReloadingStrategy for more information.
 
org.apache.commons.logging.LogFactory.getLog(FileChangedReloadingStrategy.class).debug("file 
doesn't exist " + configuration.getFile().getAbsolutePath()) ;

FYI -- I'm storing my Properties files within 
tomcat/webapps/ROOT/WEB-INF/classes.  They are loading correctly, but 
not re-loading at all.

Please let me know if *I'm* doing something wrong, or have misunderstood 
how to utilize this functionality.  If I don't hear anything in the next 
6 hours or so, I'll add an item to Bugzilla.


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