Improve your development process by adding monitoring with JavaMelody

Published on October 17, 2016 by Lars Fischer

Many software projects are constructed out of numerous components, which can sometimes 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 on. 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.


Improve your development process by adding monitoring with JavaMelody


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, as 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="" version="2.5">
  <distributable />


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

… more configuration …

Please note that I used javamelody as the name for the filter and not monitoring as 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 your project (which is nowadays very common).

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

With this configuration, you've already 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 configuraton 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.

Improve your development process by adding monitoring with JavaMelody

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




{{item.userId}}   {{item.timestamp | timestampToDate}}

About the author Lars Fischer

Lars Fischer is an IT professional with more than 15 years of experience covering a wide range of project and technology know how. His main focuses in the last decade have been: enterprise level architecture and development, integration projects; content management and project lead and management. Since 2012, he has been working as a Senior Solution Architect within the Professional Services team at Magnolia, Basel. There he designs and develops solutions and architectures for large scale and mission critical customer projects. He has also acted as principal advisor for websites like, the University of Zürich, Generali Switzerland, the Land Rover / Jaguar Club and the Canton of Basel Stadt. You can find more information on his personal website at

See all posts on Lars Fischer

Demo site Contact us Free trial