Search code examples
javajsfweb-applicationsglassfish-3

Changes in property files does not reflect in page while using Glassfish 3.1.2 server


I am using NetBeans IDE but I am using Glassfish externally(means not that which comes with NetBeans. I am using GlassFish through terminal in ubantu). In my project I am using several property file to load label on page. But the problem is when modification made to property file at run time, that changes are not reflected on page. I need to restart Glassfish server. ResourceBundle entry are made in faces-config file.

//faces-config.xml
<locale-config>
        <default-locale>en</default-locale>
</locale-config>
<resource-bundle>
    <base-name>ValidationMessages</base-name>
    <var>msg</var>
</resource-bundle>
<message-bundle>ValidationMessages</message-bundle>

I know, I need to clear cache of ResourceBundle( using ResourceBundle.clearCache(); ) when changes are made in property file. And I already tried that. This solution perfectly works in jetty. But it is ineffective when I use glassfish server.


Solution

  • A quick Google search revealed this Glassfish Bug Report. In short, clearCache() is not effective, and there doesn't appear to be a workaround at this time.

    I also came across this SO question - How to reload resource bundle in web application? - but I couldn't figure out if the main Answer would be applicable in your case; i.e. if it works on Glassfish.