Friday, July 25, 2008

Overwriting Struts Resouce Bundle Handling

Care needs to be taken when we overwrite the struts resource bundle handling,especially while overwriting the get text method in struts

This is because , if the customised gettext copies this statment

ResourceBundle bundle = LocalizedTextUtil.findResourceBundle(bundleName, resourceLocale);

where bundlename is the bundle in which property is expected

and if the property does not exist in that bundle, Struts internally looks for the entire set of bundles and searches the key. This is not what is expected
and it consumes a lot of time for each literal check and chokes the server.

A quick fix to this would be to search for the expected bundle and then check if the key which is expected is present.This can be done by using bundle.containskey() and later if it exists then by using the above statement. This reduces a lot of time wasted checking for the entire set of bundle for each property.

Your Kit : A CPU and memory Java Profiler

This is a simple kit with 15 day trial period licence which can be got from

It has both windows and linux versions.For the linux version just copy the

1. copy the into tomcat/bin

2. set the path by typing export LD_LIBRARY_PATH=/tomcat/bin

3. Add -agentlib:yjpagent to Tomcat JVM startup params as

JAVA_OPTS=" -agentlib:yjpagent -server -Xms512m -Xmx768m ......" in

To connect for the same from Windows

1 Install the windos version

2 Click on connect remotely . Enter the ip of the profiling machine

3 This gives most of the stats. For time wise distibution of thread on the running methods

click start profiling.

It also gives snapshots for the required time duration.

Free Domain Names @!