Search code examples
javaclasspathwebsphere-libertyopen-liberty

Liberty server.xml <library> <folder includes="*.properties" scanInterval="5s">: refresh


I have a customer using open liberty on Azure Kubernetes Service. They have a server.xml which refers to properties files using the mechanism. Their setup is similar to this question:

java - WAS Liberty profile - Read property using ClassLoader.getSystemResourceAsStream - Stack Overflow

My related question is: how do you get the scanInterval to actually cause the properties values to be reloaded from properties files read using the plain old Java System.getProperty()? I realize that properties files loaded from the classpath are not dynamic (as shown in this ten year old question: How to reload properties file in java - Stack Overflow), so the scanInterval attribute seems kind of irrelevant.

It seems to me you'd need to send a UNIX signal (SIGINT maybe?) to Open Liberty to cause it to restart.


Solution

  • I’m going to have to make an assumption or two because it isn’t clear from your question what you are doing, but if you have a library configured in server.xml that refers to a properties file the content would not be visible via System.getProperty(). Your code would likely be loading the properties file using Properties.load. This would require the code loading the properties to reload it if it wants to see any updates.

    I’m assuming when you mention scanInterval you are looking at the value on the fileset element, in which case that specified how often to check to look for new files being added to the directory the fileset is monitoring, it isn’t looking for updates to the individual files.

    Another thing to be aware of is that the fileset element is only looking for jar files to add to the class path, not properties files, if you want those you need to use the folder element which didn’t support scanInterval.