Sunday, 3 November 2013


To Refresh Resource Bundles in Websphere Commerce Without Server Re-Start

Given below is the code snippet which will allow you to change your property files and refresh them automatically without restarting your application server. 

  • Create a  JSP 'refreshBundles.jsp' and copy the below code snippet.
  • Upon doing the changes in the properties file, build the project(ctrl-b)
  • Use the URL below to invoke the JSP - 
    • http://<domain name>/webapp/wcs/stores/servlet/refreshBundles.jsp 

JSP - refreshBundles.jsp
--------------------------------------  
<%@ page import="java.util.*, java.lang.reflect.*"%>
<%--
  To refresh property files hit the following URL
  E:\IBM\WCD\workspace\Stores\WebContent\refreshBundles.jsp
 
  e.g. http://localhost/webapp/wcs/stores/servlet/refreshBundles.jsp
--%>
<%
Class klass = Class.forName("java.util.PropertyResourceBundle").getSuperclass();
Field field = klass.getDeclaredField("cache");
field.setAccessible(true);
WeakHashMap cache = (WeakHashMap)field.get(null);
cache.clear();
field.setAccessible(false);
%>
<body bgcolor="#aabbff">

<table height="500" align="center">

    <tr><td valign="middle">
        <table align="center" cellpadding="10" cellspacing="1" bgcolor="#ffffff">
            <tr><th bgcolor="#bbccff">
                Resource Bundles have been RESET!<br/>
                <%=new java.util.Date()%><br/>
                Go check now!!!
            </th></tr>
        </table>
    </td></tr>
</table>
</body>
--------------------------------------

1 comment:

  1. This works only on one code, how to make it work on both the nodes

    ReplyDelete