The need for monitoring

Many software projects are constructed out of many components which sometimes can be hard to monitor. Especially during the development phase of an application, it can be crucial to gain information about possible bottle necks that may prevent successful production usage of your project very early.

One possible performance metric may be the amount of possibly unnecessary SQL statements executed while using your application - this is a real use case I had in a large Magnolia project to increase performance.

Monitor your Magnolia instance by including JavaMelody

JavaMelody is an open source project providing tools and a UI to monitor Java applications.

It is not used to simulate load on your system but to provide statistics and logs for analyzing Java applications in production and during the QA phase.

To be able to monitor SQL statements like in the scenario mentioned above, please refer to the previous blog post about how to setup a JNDI based data source in Tomcat.

Magnolia project setup

Because Magnolia projects are Maven based, we include the needed library in the POM of our Magnolia webapp and also add the JRobin library for managing the created RRD log files.

Magnolia webapp POM

<!-- -->
<!-- -->

Basic web.xml setup

To provide the most basic configuration add the following configuration to web.xml:

<?xml version="1.0" encoding="UTF-8"?>
  <web-app xmlns="" xmlns:xsi="" xsi:schemaLocation="http:/" version="2.5">
	<distributable />


	  <display-name>Magnolia global filters</display-name>

	… more configuration …

Please note that I used javamelody as name for the filter and not monitoring like in most of the examples provided on the web. This is because some of the options shown below will not work if you are going to use Java 8 with you’re project - which is nowadays very common.

See this issue on GitHub for more information about this problem.

With this configuration, you already have configured JavaMelody to be available with your Magnolia project. After starting your Magnolia instance, go to


to access the JavaMelody UI on your server. The name „monitoring“ is the default name for accessing the JavaMelody web interface.

Setup with advanced configuration options

This blog entry written by Siegfried Goeschl provides a nice introduction on how to configure some of the options for usage of JavaMelody within your Java based web application.

Check the refined filter configuration below:


The extended filter configuration shows you how to

  • add credentials for basic authentication
  • modify the path where JavaMelody can be accessed
  • change the directory for storage of historical data

More information

Please consult the official project documentation on GitHub for more information on how to configure JavaMelody. By adding this tool to your Magnolia project, you can quickly gain a tool for monitoring and for gaining statistics about the overall performance of your application.


The screenshot below shows an example of SQL statements executed against the JCR repository while using Magnolia CMS AdminCentral. This is only one of many useful reports you get automatically when integrating JavaMelody into your Magnolia or Java web application.

By including just a few lines of configuration, we were able to gain important performance metrics about our Java based application.