File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes reloading  property files after tomcat has started. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "reloading  property files after tomcat has started." Watch "reloading  property files after tomcat has started." New topic

reloading property files after tomcat has started.

peter cooke
Ranch Hand

Joined: Mar 16, 2004
Posts: 317
Thanks to any one that can fill in my missing knowledge.
What is the proper way to reload altered I18N/L10N property files without restarting the app or app server.

We have a custom class loader that is loading a couple of localization property files that do not live within the tomcat directory structure at server start. It works well. The customer does not like having to restart a server every time they change the property files. They want the app to either update itself or be able to tell the app to reread the property files.

Running tomcat 5.5.28, Struts 2( 2.1.8), xwork-core 2.1.6 (2.1.8 has a reloadable class loader), JSON plugin, and a dash of Spring, and a heavy dose of our own Swiss army knife utilities.

Options I have found so far
1) cannot do it. have to reboot.
2) can only reload property files from the tomcat console/manager app.
3) can do it but have to throw out classloader. (tried it, does not work for me) I have a controller class, it will clear out the property files but does not load up new ones. Even if I logged out and log back in the changes do not appear.

4) write a re-loadable classloader. If I could figure out how to get the class loader from the system the above try block would simply be .

5) Javadoc indicates all that I need to is tell LocalizedTextUtil that it has a new addDefaultResourceBundle() . but no one on the internet says this will work. It did not work for me

6)Have the servlet context get the resource as a stream AGAIAN. But when I do that, all I get is a null pointer error in p.load. I am not getting a file not found, and another app is able to read the property files at the path used here. Why can the server read the file on startup, but not after it is running?

CIAO Peter M. Cooke
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Java 6 provides the ResourceBundle.Control class which allows you to control the loading and reloading of ResourceBundles. Perhaps that's what you need?
peter cooke
Ranch Hand

Joined: Mar 16, 2004
Posts: 317
my customer cannot go above java 5.
that said I ran into the author of our internal classloader. He said I need to look at java's SoftCache and getting it free up its cached content.

Going down that trail.
I found

But then run into the following problems:
  • Having lots of fun trying to get a resource bundle from outside the tomcat home directory. does not look possible -that is what external class loaders are for.
  • how do I determine which SoftCache to clear
  • although I want to clear the cache, there is no clear way to reload it.

    I agree. Here's the link:
    subject: reloading property files after tomcat has started.
    It's not a secret anymore!