Jolokia Overview and Installation

Bogdan Socaciu
RevianLabs
Published in
3 min readFeb 4, 2021

Introduction

The Java Management Extensions (JMX) technology is a standard part of the Java Platform, Standard Edition (Java SE platform). It provides a simple, standard way of managing resources such as applications, devices, and services. Because the JMX technology is dynamic, you can use it to monitor and manage resources as they are created, installed and implemented. You can also use the JMX technology to monitor and manage the Java Virtual Machine (Java VM).

Jolokia is a JMX-HTTP bridge giving an alternative to JMX Remoting (JSR-160) connectors supported by Java JMX. It is an agent based approach with support for many platforms. In addition to basic JMX operations it enhances JMX remoting with unique features like bulk requests and fine grained security policies.

Overview

  • Jolokia uses only one HTTP port for bean management and can centralize beans.
  • Jolokia JVM agent is very flexible. It can connect via the JVM dynamically to a running process.
  • Jolokia agents create REST endpoints for REST-oriented web consoles like Hawtio to access.
  • The Jolokia agents are deployed as web applications and can attach to MBeanServers dinamically
  • This tool is very useful if you don’t have a java instalation client-side.

Main features

  • Bulk requests. Multiple JMX calls within a single request
  • JSON Serialization.
  • Server-side history. Keeps previous fetched values in a non-persistent cache on the server side, along with a time stamp. This is especially useful to calculate the change of JMX attributes without need of a client storage.
  • MBeanServer aggregation. Can merge multiple MBeanServers into one virtual container. This way you don’t need to know which MBean comes from which server :)
  • Firewall friendly. Easy to configure the firewall because it only uses the HTTP port (unlike RMI, which is using a random port)

Step-by-step guide

  1. Let’s start with a fresh tomcat installation. Download Apache Tomcat and the latest Jolokia Unsecured war (https://jolokia.org/download.html).
  2. Rename the downloaded jolokia war file to jolokia.war for easier access within Tomcat.
  3. Extract Apache Tomcat.
  4. Copy jolokia.war in the webapps folder of the Apache Tomcat installation.
  5. Start Apache Tomcat (“catalina start” or “./catalina start”).
  6. Done

Jolokia is now deployed and running. Test it by following this URL:

http://localhost:8080/jolokia/

In order to verify the JMX to JSON feature access the following URL:

http://localhost:8080/jolokia/read/java.lang:type=Memory/HeapMemoryUsage

Basic API Explanation:

  1. read = asks jolokia for a GET request in order to “read” the given resource (bean)
  2. java.lang:type=Memory/HeapMemoryUsage = the resource (bean) to be read
  3. java.lang = Bean class
  4. type=Memory = Bean type
  5. HeapMemoryUsage = Bean name

Tip

  • Install a JSON Viewer browser extension, it can prove to be helpful. I recommend JSONView (available for Chrome, Firefox) or JSON Peep for Safari.

What’s next?

References

--

--

Bogdan Socaciu
RevianLabs

Co-founder @RevianLabs | Professional thing-fixer | DevOps Engineer | Gopher | Finance enthusiast