Monitor Liferay cache behaviour with JConsole

A crucial point for any project is the use of cache strategies, especially when you try to implement a project the first time on a new infrastructure. Therefore I will give some hints  how you can easily get confident with our ootb caching strategies.

So lets get started with my prerequisites.

You download any tomcat bundle of liferay, I used 606 our latest community edition of the portal with tomcat 6.

As JConsole needs to connect to tomcat you will need to give tomcat some extra configuration. I added the necessary opts to (on windows that would be catalina.bat) somewhere near line 257.

(I have my stored in 606workspace/bundles/tomcat-6.0.29/bin)




Now we need to tell liferay that we would like to evaluate the ehcache statistics. We need an entry in for that, as this costs a small portion of performance it is disable be default.


My file is stored in /606workspace/bundles/, where bundles is the directory which includes tomcat*/bin


 # Set this to true to enable Ehcache statistics.


So much for the setup, we can start the portal now (exec in a shell or double click startup.bat on windows in tomcat bin folder)


Once the Portal is started go forth an create some WebContent in Liferay CMS and put the article on any page.

On my end I just used


and placed a Web Content Display Portlet on the page which used one content I have created earlier.

Screenshot from my browser on http://localhost:8080/web/guest/home with a web content display portlet


So now we can start jconsole from shell or commandline by typing in


hit enter and it starts rightaway, as long as you have a full jdk installed.

JConsole has a startup screen

JConsole StartupScreen


We will choose org.apache.catalina... to connect to tomcat and directly land on the overview page in jconsole. To look at the cache hits we navigate to MBeans and then on the left tree we will walk following path.


Then you will have a lot of classes inside this container, which represent the caches of different entities etc., as we want to monitor the statistics of rendered journal content, the following class is what you want to find:

Once you have discovered the class unravel the details by clicking on it and select



JConsole Explorer view with Journal selected


Now the cache statistics overview will show up and every time you refresh your browser on 


the statistics will change.

Jconsole monitor snippet looking at a rendered journal cache


Have fun exploring

Very nice post! I shared this with my Sys Admin class today emoticon
Great post armin.. very helpfull
Great info...thnx for sharing with us..
Only one improvement suggestion: Add the CATALINA_OPTS to / setenv.bat. Create the file if it isn't there (but it is contained in Liferay's tomcat bundles). This file will survive a tomcat update as it's not contained in tomcat itself and so you can easily isolate your from tomcat's changes.
Great and useful post, even as of today's version of Liferay Portal