For those that use WebSphere Commerce, especially if you’re taking advantage of internationalization and localization, you’ve used many a resource bundles. You also understand how challenging it can be when you have to consistently modify your properties, only to have to restart your application server in order to view the updates.
Here is a solution that will allow you to change your property files, and refresh them automatically without restarting your application server. This piece of logic resides in a JSP page, as I can just copy it around to the projects I’m working on.
Here is the JSP code that I leverage in order to refresh my property resource bundles.
<%@ page import="java.util.*, java.lang.reflect.*"%> <% Class klass = Class.forName("java.util.ResourceBundle").getSuperclass(); Field field = klass.getDeclaredField("cacheList"); field.setAccessible(true); sun.misc.SoftCache cache = (sun.misc.SoftCache)field.get(null); cache.clear(); field.setAccessible(false); %> <body> <p style="text-align: center;">The Property Resource Bundles were reset on <%=new java.util.Date()%>.</p> </body>
2 thoughts on “Refresh Resource Bundles in WebSphere Commerce”
I was interested in this. Since we have multiple locales, this would help us in avoiding few restarts
But i am getting error.
Caused by: java.lang.NoSuchFieldException: cacheList
at java.lang.Class.getDeclaredFieldImpl(Native Method)
Did you encounter anything like this.
hi, I’m also getting the same Error, Would you please elaborate how to do this?