Chapter 6. Jolokia Protocol

Jolokia uses a JSON-over-HTTP protocol which is described in this chapter. The communication is based on a request-response paradigm, where each request results in a single response.

Jolokia requests can be sent in two ways: Either as a HTTP GET request, in which case the request parameters are encoded completely in the URL. Or as a POST request where the request is put into a JSON payload in the HTTP request's body. GET based requests are mostly suitable for simple use cases and for testing the agent via a browser. The focus here is on simplicity. POST based requests uses a JSON representation of the request within the HTTP body. They are more appropriate for complex requests and provide some additional features (e.g. bulk requests are only possible with POST).

The response returned by the agent uses always JSON for its data representation. It has the same format regardless whether GET or POST requests are used.

The rest of this chapter is divided into two parts: First, the general structure of requests and responses are explained after which the representation of Jolokia supported operations defined.

Unfortunately the term operation is used in different contexts which should be distinguished from one another. Jolokia operations denote the various kind of Jolokia requests, whereas JMX operations are methods which can be invoked on an JMX MBean. Whenever the context requires it, this documents uses Jolokia or JMX as prefix.

6.1. Requests and Responses

Jolokia knows about two different styles of handling requests, which are distinguished by the HTTP method used: GET or POST. Regardless of what method is used, the agent doesn't keep any state on the server side (except of course that MBeans are obviously stateful most of the time). So in this aspect, the communication can be considered REST like[7].

6.1.1. GET requests

The simplest way to access the Jolokia agent is by sending HTTP GET requests. These requests encode all their parameters within the access URL. Typically, Jolokia uses the path-info part of an URL to extract the parameters. Within the path-info, each part is separated by a slash (/). In general, the request URL looks like


The <base-url> specifies the URL under which the agent is accessible. It normally looks like http://localhost:8080/jolokia, but depends on your deployment setup. The last part of this URL is the context root of the deployed agent, which by default is based on the agent's filename (e.g. jolokia.war). <type> specifies one of the supported Jolokia operations (described in the next section), followed by one or more operation-specific parameters separated by slashes.

For example, the following URL executes a read Jolokia operation on the MBean java.lang:type=Memory for reading the attribute HeapMemoryUsage (see Section 6.2.1, “Reading attributes (read)”). It is assumed, that the agent is reachable under the base URL http://localhost:8080/jolokia:


If one of the request parts contain a slash (/) (e.g. as part of you bean's name) it needs to be escaped. An exclamation mark (!) is used as escape character[8]. An exclamation mark itself needs to be doubled for escaping. Any other characted preceded by an exclamation mark is taken literally. Table Table 6.1, “Escaping rules” illustrates the escape rules as used in GET requests. Also, if quotes are part of an GET request the need to be escaped with !".

Table 6.1. Escaping rules

Escaped Unescaped
!/ /
!! !
!" "
!(anything else) (anything else)

For example, to read the atrribute State on the MBean named jboss.jmx:alias=jmx/rmi/RMIAdaptor, an access URL like this has to be constructed:


Client libraries like JMX::Jmx4Perl do this sort of escaping transparently.

Escaping can be avoided alltogether if a slightly different variant for a request is used (which doesn't look that REST-stylish, though). Instead of providing the information as path-info, a query parameter p can be used instead. This should be URL encoded, though. For the example above, the alternative is


This format must be used for GET requests containing backslashes (\) since backslashes can not be sent as part of an URL at all.

6.1.2. POST requests

POST requests are the most powerful way to communicate with the Jolokia agent. There are fewer escaping issues and it allows for features which are not available with GET requests. POST requests uses a fixed URL and put their payload within the HTTP request's body. This payload is represented in JSON, a data serialization format originating from the JavaScript world.

The JSON format for a single request is a JSON object, which is essentially a map with keys (or attributes) and values. All requests have a common mandatory attribute, type, which specifies the kind of JMX operation to perform. The other attributes are either operation specific as described in Section 6.2, “Jolokia operations” or are processing parameters which influence the overall behaviour and can be mixed in to any request. See Section 6.3, “Processing parameters” for details. Operation specific attributes can be either mandatory or optional and depend on the operation type. In the following, if not mentioned otherwise, attributes are mandatory. Processing parameters are always optional, though.

A sample read request in JSON format looks like the following example. It has a type "read" (case doesn't matter) and the three attributes mbean, attribute and path which are specific to a read request.

Example 6.1. JSON Request

    "type" : "read",
    "mbean" : "java.lang:type=Memory",
    "attribute" : "HeapMemoryUsage",
    "path" : "used",

Each request JSON object results in a single JSON response object contained in the HTTP answer's body. A bulk request contains multiple Jolokia requests within a single HTTP request. This is done by putting individual Jolokia requests into a JSON array:

    "type" : "read",
    "attribute" : "HeapMemoryUsage",
    "mbean" : "java.lang:type=Memory",
    "path" : "used",
    "type" : "search"
    "mbean" : "*:type=Memory,*",

This request will result in a JSON array containing multiple JSON responses within the HTTP response. They are returned in same order as the requests in the initial bulk request.

6.1.3. Responses

Responses are always encoded in UTF-8 JSON, regardless whether the requst was a GET or POST request. In general, two kinds of responses can be classified: In the normal case, a HTTP Response with response code 200 is returned, containing the result of the operation as a JSON payload. In case of an error, a 4xx or 5xx code will be returned and the JSON payload contains details about the error occured (e.g. 404 means "not found"). (See this page for more information about HTTP error codes..). If the processing option ifModifiedSince is given and the requested value as been not changed since then, a response code of 304 is returned. This option is currently only supported by the LIST request, for other request types the value is always fetched.

In the non-error case a JSON response looks mostly the same for each request type except for the value attribute which is request type specific.

The format of a single Jolokia response is

Example 6.2. JSON Response

   "value": .... ,
   "status" : 200,
   "timestamp" : 1244839118,
   "request": {
               "type": ...,
               {"value": ... ,
                "timestamp" : 1244839045
               }, ....

For successful requests, the status is always 200 (the HTTP success code). The timestamp contains the epoch time[9] when the request has been handled. The request leading to this response can be found under the attribute request. Finally and optionally, if history tracking is switched on (see Section 6.5, “Tracking historical values”), an entry with key history contains a list of historical values along with their timestamps. History tracking is only available for certain type of requests (read, write and exec). The value is specific for the type of request, it can be a single scalar value or a monster JSON structure.

If an error occurs, the status will be a number different from 200. An error response looks like

    "error":"java.lang.IllegalArgumentException: Invalid request type 'java.lang:type=Memory'",
    "stacktrace":"java.lang.IllegalArgumentException: Invalid request type 'java.lang:type=Memory'\n
                  \tat org.cpan.jmx4perl.JmxRequest.extractType(Unknown Source)\n
                  \tat org.cpan.jmx4perl.JmxRequest.<init>(Unknown Source) ...."

For status codes it is important to distinguish status codes as they appear in Jolokia JSON response objects and the HTTP status code of the (outer) HTTP response. There can be many Jolokia status codes, one for each Jolokia request contained in the single HTTP request. The HTTP status code merely reflect the status of agent itself (i.e. whether it could perform the operation at all), whereas the Jolokia response status reflects the result of the operation (e.g. whether the performed operation throws an exception). So it is not uncommon to have an HTTP status code of 200, but the contained JSON response(s) indicate some errors.

I.e. the status has a code in the range 400 .. 499 or 500 .. 599 as it is specified for HTTP return codes. The error member contains an error description. This is typically the message of an exception occured on the agent side[10]. Finally, error_type contains the Java class name of the exception occured. The stacktrace contains a Java stacktrace occured on the server side (if any stacktrace is available).

For each type of operation, the format of the value entry is explained in Section 6.2, “Jolokia operations”

6.1.4. Paths

An inner path points to a certain substructure (plain value, array, hash) within a a complex JSON value. Think of it as something like "XPath lite". This is best explained by an example:

The attribute HeapMemoryUsage of the MBean java.lang:type=Memory can be requested with the URL http://localhost:8080/jolokia/read/java.lang:type=Memory/HeapMemoryUsage which returns a complex JSON structure like

  "status" : 200,
  "value" :  {
               "committed" : 18292736,
               "used" : 15348352,
               "max" : 532742144,
               "init" : 0
  "request" : { .... },
  "timestamp" : ....

In order to get to the value for used heap memory you should specify an inner path used, so that the request http://localhost:8080/jolokia/read/java.lang:type=Memory/HeapMemoryUsage/used results in a response of 15348352for the value:

  "status" : 200,
  "value" :  15348352,
  "request" : { .... },
  "timestamp" : ....

If the attribute contains arrays at some level, use a numeric index (0 based) as part of the inner path if you want to traverse into this array.

For both, GET and POST requests, paths must be escaped as described in Table 6.1, “Escaping rules” when they contain slashes (/) or exclamation marks (!).

Paths support wildcards * in a simple form. If given as a path part exclusively, it matches any entry and path matching continues on the next level. This feature is especially useful when using pattern read request together with paths. See Section 6.2.1, “Reading attributes (read)” for details. A * mixed with other characters in a path part has no special meaning and is used literally.

6.2. Jolokia operations

6.2.1. Reading attributes (read)

Reading MBean attributes is probably the most used JMX method, especially when it comes to monitoring. Concerning Jolokia, it is also the most powerful one with the richest semantics. Obviously the value of a single attribute can be fetched, but Jolokia supports also fetching of a list of given attributes on a single MBean or even on multiple MBeans matching a certain pattern.

Reading attributes are supported by both kinds of requests, GET and POST.

Don't confuse fetching multiple attributes on possibly multiple MBeans with bulk requests. A single read request will always result in a single read response, even when multiple attribute values are fetched. Only the single response's structure of the value will differ depending on what kind of read request was performed.

A read request for multiple attributes on the same MBean is initiated by giving a list of attributes to the request. For a POST request this is an JSON array, for a GET request it is a comma separated list of attribute names (where slashes and exclamation marks must be escaped as described in Table 6.1, “Escaping rules”). If no attribute is provided, then all attributes are fetched. The MBean name can be given as a pattern in which case the attributes are read on all matching MBeans. If a MBean pattern and multiple attributes are requested, then only the value of attributes which matches both are returned, the others are ignored.

Paths can be used with pattern and multiple attribute read as well. In order to skip the extra value levels introduced by a pattern read, the wildcard * can be used. For example, a read request for the MBean Pattern java.lang:type=GarbageCollector,* for the Attribute LastGcInfo returns a complex structure holding information about the last garbage collection. If one is interested only for the duration of the garbage collection, a path used could be used if this request wouldn't be a pattern request (i.e. refers a specific, single MBean). But in this case since a nested map with MBean and Attribute names is returned, the path */*/used has to be used in order to skip the two extra levels for applying the path. The two levels are returned nevertheless, though. Note that in the following example the final value is not the full GC-Info but only the value of its used entry:

value: {
   "java.lang:name=PS MarkSweep,type=GarbageCollector": {
        LastGcInfo: null
   "java.lang:name=PS Scavenge,type=GarbageCollector": {
        LastGcInfo: 7

The following rule of thumb applies:

  • If a wildcard is used, everything at that point in the path is matched. The next path parts are used to match from there on. All the values on this level are included.
  • Every other path part is literally compared against the values on that level. If there is a match, this value is removed in the answer so that at the end you get back a structure with the values on the wildcard levels and the leaves of the matched parts.
  • If used with wildcards, paths behave also like filters. E.g. you can use a path */*/used on the MBean pattern java.lang:* and get back only that portions which contains "used" as key, all others are ignored. GET read request

The GET URL for a read request has the following format:

<base-url>/read/<mbean name>/<attribute name>/<inner path>

Table 6.2. GET Read Request

Part Description Example
<mbean name> The ObjectName of the MBean for which the attribute should be fetched. It contains two parts: A domain part and a list of properties which are separated by :. Properties themselves are combined in a comma separated list of key-value pairs. This name can be a pattern in which case multiple MBeans are queried for the attribute value. java.lang:type=Memory
<attribute name> Name of attribute to read. This can be a list of Attribute names separated by comma. Slashes and exclamations marks need to be escaped as described in Table 6.1, “Escaping rules”. If no attribute is given, all attributes are read. HeapMemoryUsage
<inner path> This optional part describes an inner path as described in Section 6.1.4, “Paths” used

With this URL the used heap memory can be obtained:

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

A the keys available for read POST requests are shown in the following table.

Table 6.3. POST Read Request

Key Description Example
type read
mbean MBean's ObjectName which can be a pattern java.lang:type=Memory
attribute Attribute name to read or a JSON array containing a list of attributes to read. No attribute is given, then all attributes are read. HeapMemoryUsage, [ "HeapMemoryUsage", "NonHeapMemoryUsage" ]
path Inner path for accessing the value of a complex value (Section 6.1.4, “Paths”) used

The following request fetches the number of active threads:

} Read response

The general format of the JSON response is described in Section 6.1.3, “Responses” in detail. A typical response for an attribute read operation for an URL like


looks like

             }, ....

The value contains the response's value. For simple data types it is a scalar value, more complex types are serialized into a JSON object. See Section 6.4, “Object serialization” for detail on object serialization.

For a read request to a single MBean with multiple attributes, the returned value is a JSON object with the attribute names as keys and their values as values. For example a request to http://localhost:8080/jolokia/read/java.lang:type=Memory leads to

 "timestamp": 1317151518,
 "status": 200,
 "request": {"mbean":"java.lang:type=Memory","type":"read"},
   "Verbose": false,
   "ObjectPendingFinalizationCount": 0,
   "NonHeapMemoryUsage": {"max":136314880,"committed":26771456,"init":24317952,"used":15211720},
   "HeapMemoryUsage": {"max":129957888,"committed":129957888,"init":0,"used":2880008}

A request to a MBean pattern returns as value a JSON object, with the MBean names as keys and as value another JSON object with the attribute name as keys and the attribute values as values. For example a request http://localhost:8080/jolokia/read/java.lang:type=*/HeapMemoryUsage returns something like

 "timestamp": 1317151980,
 "status": 200,
 "request": {"mbean":"java.lang:type=*","attribute":"HeapMemoryUsage","type":"read"},
 "value": { 
    "java.lang:type=Memory": { 
      "HeapMemoryUsage": {"max":129957888,"committed":129957888,"init":0,"used":3080912}

6.2.2. Writing attributes (write)

Writing an attribute is quite similar to reading one, except that the request takes an additional value element. GET write request

Writing an attribute wit an GET request, an URL with the following format has to be used:

<base url>/write/<mbean name>/<attribute name>/<value>/<inner path>

Table 6.4. GET Write Request

Part Description Example
<mbean name> MBean's ObjectName java.lang:type=ClassLoading
<attribute name> Name of attribute to set Verbose
<value> The attribute name to value. The value must be serializable as described in Section 6.4.2, “Request parameter serialization”. true
<path> Inner path for accessing the parent object on which to set the value. (See also Section 6.1.4, “Paths”). Note, that this is not the path to the attribute itself, but to the object carrying this attribute. With a given path it is possible to deeply set an value on a complex object.

For example, you can set the garbage collector to verbose mode by using something like

http://localhost:8080/jolokia/write/java.lang:type=Memory/Verbose/true POST write request

The keys which are evaluated for a POST write request are:

Table 6.5. POST Write Request

Key Description Example
type write
mbean MBean's ObjectName java.lang:type=ClassLoading
attribute Name of attribute to set Verbose
value The attribute name to value. The value must be serializable as described in Section 6.4.2, “Request parameter serialization”. true
path An optional inner path for specifying an inner object on which to set the value. See Section 6.1.4, “Paths” for more on inner paths. Write response

As response for a write operation the old attribute's value is returned. For a request


you get the answer (supposed that verbose mode was switched off for class loading at the time this request was sent)

   "request": {

The response is quite similar to the read operation except for the additional value element in the request (and of course, the different type).

6.2.3. Executing JMX operations (exec)

Beside attribute provides a way for the execution of exposed JMX operations with optional arguments. The same as for writing attributes, Jolokia must be able to serialize the arguments. See Section 6.4, “Object serialization” for details. Execution of overloaded methods is supported. The JMX specifications recommends to avoid overloaded methods when exposing them via JMX, though. GET exec request

The format of an GET exec request is

<base url>/exec/<mbean name>/<operation name>/<arg1>/<arg2>/....

Table 6.6. GET Exec Request

Part Description Example
<mbean name> MBean's ObjectName java.lang:type=Threading
<operation name> Name of the operation to execute. If this is an overloaded method, it is mandatory to provide a method signature as well. A signature consist the fully qualified argument class names or native types, separated by commas and enclosed with parentheses. For calling a non-argument overloaded method use () as signature. loadUsers(java.lang.String,int)
<arg1>, <arg2>, ... String representation for the arguments required to execute this operation. Only certain data types can be used here as described in Section 6.4.2, “Request parameter serialization”. "true","true"

The following request will trigger a garbage collection:

http://localhost:8080/jolokia/exec/java.lang:type=Memory/gc POST exec request

Table 6.7. POST Exec Request

Key Description Example
type exec
mbean MBean's ObjectName java.lang:type=Threading
operation The operation to execute, optionally with a signature as described above. dumpAllThreads
arguments An array of arguments for invoking this operation. The value must be serializable as described in Section 6.4.2, “Request parameter serialization”. [true,true]

The following request dumps all threads (along with locked monitors and locked synchronizers, thats what the boolean arguments are for):

} Exec response

For an exec operation, the response contains the return value of the operation. null is returned if either the operation returns a null value or the operation is declared as void. A typical response for an URL like


looks like

   "request": {

The return value get serialized as described in Section 6.4, “Object serialization”.

6.2.4. Searching MBeans (search)

With the Jolokia search operation the agent can be queried for MBeans with a given pattern. Searching will be performed on every MBeanServer found by the agent. GET search request

The format of the search GET URL is:


This mode is used to query for certain MBean. It takes a single argument pattern for specifying the search parameter like in


You can use patterns as described here, i.e. it may contain wildcards like * and ?. The Mbean names matching the query are returned as a list within the response. POST search request

A search POST request knows the following keys:

Table 6.8. POST Search Request

Key Description Example
type search
mbean The MBean pattern to search for java.lang:*

The following request searches for all MBeans registered in the domain java.lang

} Search response

The answer is a list of MBean names which matches the pattern or an empty list if there was no match.

For example, the request


results in

   "value": [
   "request": {

The returned MBean names are properly quoted so that they can be directly used as input for other requests.

6.2.5. Listing MBeans (list)

The list operation collects information about accessible MBeans. This information includes the MBean names, their attributes, operations and notifications along with type information and description (as far as they are provided by the MBean author which doesn't seem to be often the case). GET list request

The GET request format for a Jolokia list request is

<base-url>/list/<inner path>

The <inner path>, as described in Section 6.1.4, “Paths” specifies a subset of the complete response. You can use this to select a specific domain, MBean or attribute/operation. See the next section for the format of the complete response. POST list request

A list POST request has the following keys:

Table 6.9. POST list Request

Key Description Example
type list
path Inner path for accessing the value of a subset of the complete list (Section 6.1.4, “Paths”). java.lang/type=Memory/attr

The following request fetches the information about the MBean java.lang:type=Memory

} List response

The value has the following format:

  <domain> : 
    <prop list> : 
      "attr" : 
        <attr name> : 
          "type" : <attribute type>,
          "desc" : <textual description of attribute>,
          "rw"   : true/false
      "op" :
         <operation name> :
           "args" : [
                       "type" : <argument type>
                       "name" : <argument name>
                       "desc" : <textual description of argument>
           "ret"  : <return type>,
           "desc" : <textual description of operation>
      "not" : 
         "name" : <name>,
         "desc" : <desc>,
         "types" : [ <type1>, <type2> ]

The domain name and the property list together uniquely identify a single MBean. The property list is in the so called canonical order, i.e. in the form "<key1>=<val1>,<key2>=<val2>,.." where the keys are ordered alphabetically. Each MBean has zero or more attributes and operations which can be reached in an MBeans JSON object with the keys attr and op respectively. Within these groups the contained information is explained above in the schema and consist of Java types for attributes, arguments and return values, descriptive information and whether an attribute is writable (rw == true) or read-only.

As for reading attributes you can fetch a subset of this information using an path. E.g a path of domain/prop-list would return the value for a single bean only. For example, a request


results in an answer

 } Restrict depth of the returned tree

The optional parameter maxDepth can be used to restrict the depth of the return tree. Two value are possible: A maxDepth of 1 restricts the return value to a map with the JMX domains as keys, a maxDepth of 2 truncates the map returned to the domain names (first level) and the MBean's properties (second level). The final values of the maps don't have any meaning and are dummy values.

6.2.6. Getting the agent version (version)

The Jolokia command version returns the version of the Jolokia agent along with the protocol version. GET version request

The GET URL for a version request has the following format:


For GET request the version part can be omitted since this is the default command if no command is provided as path info. POST version request

A version POST request has only a single key type which has to be set to version. Version response

The response value for a version request looks like:

              "config": {
                 "agentDescription": "Servicemix ESB",
                 "agentId": "EF87BE-jvm",
                 "agentType": "jvm",
                 "serializeException": "false"
              "info": {
                 "product": "glassfish",
                 "vendor": "Oracle",
                 "version": "4.0",
                 "extraInfo": {
                    "amxBooted": false

protocol in the response value contains the protocol version used, agent is the version of the Jolokia agent. See Section 6.8, “Jolokia protocol versions” for the various protocol versions and the interoperability. If the agent is able to detect the server, additional meta information about this server is returned (i.e. the product name, the vendor and optionally some extra information added by the server detector).

6.3. Processing parameters

Jolokia operations can be influenced by so-called processing parameters. These parameters are provided differently for POST and GET requests.

For GET request, the processing parameter are given as normal query parameters:

<GET request URL>?param1=value1&param2=value2&...

For example the request


will limit the response to at max 100 values.

POST request take the processing instructions within the JSON request below the key config:

    "type" : "list"
    "config" : {
                 "maxObjects" : 100

If a POST request carries also query parameters in the URL, these processing parameters are merged with the ones given within the request. Configuration options given in the request take precedence over the ones given as query parameters.

The list of known processing parameters is:


Maximum depth of the tree traversal into a bean's properties. The maximum value as configured in the agent's configuration is a hard limit and cannot be exceeded by a query parameter.


For collections (lists, maps) this is the maximum size.


Number of objects to visit in total. A hard limit can be configured in the agent's configuration.


If set to "true", a Jolokia operation will not return an error if an JMX operation fails, but includes the exception message as value. This is useful for e.g. the read operation when requesting multiple attributes' values. Default: false


The MIME type to return for the response. By default, this is text/plain, but it can be useful for some tools to change it to application/json. Init parameters can be used to change the default mime type. Only text/plain and application/json are allowed. For any other value Jolokia will fallback to text/plain.


Defaults to true to return the canonical format of property lists. If set to false then the default unsorted property list is returned.


If set to true, then in case of an error the stack trace is included. With false no stack trace will be returned, and when this parameter is set to runtime only for RuntimeExceptions a stack trace is put into the error response. Default is true if not set otherwise in the global agent configuration.


If this parameter is set to true then a serialized version of the exception is included in an error response. This value is put under the key error_value in the response value. By default this is set to false except when the agent global configuration option is configured otherwise.


If this parameter is given, its value is interpreted as epoch time (seconds since 1.1.1970) and if the requested value did not change since this time, an empty response (with no value) is returned and the response status code is set to 304 ("Not modified"). This option is currently only supported for LIST requests. The time value can be extracted from a previous' response timestamp.

6.4. Object serialization

Jolokia has some object serialization facilities in order to convert complex Java data types to JSON and vice versa. Serialization works in both ways in requests and responses, but the capabilities differ.

Complex data types returned from the agent can be serialized completely into a JSON value object. It can detect cycles in the object graph and provides a way to limit the depth of serialization. For certain types (like File or ObjectName) it uses simplifier to not expose internal and redundant information.

Object values used for values in write operations and arguments in exec, type support is limited to a handful of data types.

6.4.1. Response value serialization

Jolokia can serialize any object into a JSON representation when generating the response. It uses some specific converters for certain well known data type with a generic bean converter as fallback.

The following types are directly supported:

  • Arrays and java.util.List are converted to JSON arrays
  • java.util.Map gets converted into a JSON object. Note, however, that JSON Object keys are always strings.
  • Enums are converted to their canonical name.[11]
  • is converted in a JSON object, with the keys taken from the CompositeData's key set and the value are its values.
  • is serialized differently depending on its internal structure. See below for a detailed explanation of this serialization mechanism including examples.
  • java.lang.Class is converted to a JSON object with keys name (the class name) and interfaces (the implemented interfaces, if any)
  • becomes a JSON object with keys name (file name), modified (date of last modification), length (file size in bytes), directory (whether the file is a directory), canonicalPath (the canonical path) and exists.
  • is converted into a JSON object with the single key objectName.
  • becomes a JSON object with the key url containing the URL as String.
  • java.util.Date is represented in an ISO-8601 format. When used with a path time the milliseconds since 1.1.1970 00:00 UTC are returned.
  • org.w3c.dom.Element is translated into a JSON object with the properties name, value and hasChildNodes.
  • java.math.BigInteger becomes a JSON object with the key bigint containing the big integer value as String.

Primitive and simple types (like String) are directly converted into their string presentation. All objects not covered by the list above are serialized in JSON objects, where the keys are the public bean properties of the object and the values are serialized (recursively) as described.

TabularData serialization depends on the type of the index. It is serialized into one or multiple nested JSON objects where the keys are derived from its TabularType.indexNames(). If there is a single valued index with a simple type (i.e. an instance of, the index's value is the key and a TabularData's row (which in turn is a CompositeData) is a map. With multi valued, simple typed, keys, the map is nested (first level: first index's value, second level: second index's value and so on). For the serialization of TabularData resulting from a MXBean translation for maps, see Section 6.4.3, “Jolokia and MXBeans”. If any of the declared index keys of a TabularData is a complex type (i.e. not a SimpleType), then this simple serialization into maps of maps is not possible anymore, since for JSON, map keys must be simple types. In this case, a more generic serialization is used in which case an JSON object with two keys is returned: indexNames is an array with the TabularData's indexes as names and values is the array containing the values as JSON object with the corresponding rows as values (including the indexes).

For example if there is a single valued key key, then the returned JSON looks like

  "mykey1" : { "key" : "mkey1", "item" : "value1", .... }
  "mykey2" : { "key" : "mkey2", "item" : "value2", .... }

For multi valued keys of simple open types (i.e. TabularType.getIndexNames()) is a list with more than one element but all of them are simple types), the returned JSON structure looks like (index names here are key and innerkey):

  "mykey1" : {
    "myinner1" : { "key" : "mkey1", "innerkey" : "myinner1", "item" : "value1", .... }
    "myinner2" : { "key" : "mkey1", "innerkey" : "myinner2", "item" : "value1", .... }
  "mykey2" : {
    "second1" : { "key" : "mkey2", "innerkey" : "second1", "item" : "value1", .... }
    "second2" : { "key" : "mkey2", "innerkey" : "second2", "item" : "value1", .... }

If keys are used, which themselves are complex objects (like CompositeData), this hierarchical map structure can not be used. In this case an object with two keys is returned: "indexNames" holds the name of the key index and "values" is an array of all rows which are represented as JSON objects:

  "indexNames" : [ "key", "innerkey" ],
  "values" : [
    { "key" : "mykey1", "innerkey" : { "name" : "a", "number" : 4711 }, "item" : "value1", .... },
    { "key" : "mykey2", "innerkey" : { "name" : "b", "number" : 815 }, "item" : "value2", .... },

Beside this special behaviour for TabularData, serialization can be influenced by certain processing parameters given with the request (see Section 6.3, “Processing parameters”). I.e. the recursive process of JSON serialization can be stopped when the data set gets too large. Self and other circular references are detected, too. If this happen, special values indicate the truncation of the generated JSON object.


This label is used when a property contains a self reference

[Depth limit .... ]

When a depth limit is used or the hard depth limit is exceeded, this label contains a string representation of the next object one level deeper. (see Section 6.3, “Processing parameters”, parameter maxDepth)

[Reference .... ]

If during the traversal an object is visited a second time, this label is used in order to break the cycle.

[Object limit exceeded]

The total limit of object has been exceeded and hence the object are not deserialized further. (see Section 6.3, “Processing parameters”, parameters maxCollectionSize and maxObjects)

6.4.2. Request parameter serialization

Serialization in the upstream direction (i.e. when sending values for write operations or arguments for exec operations) differs from from the object serializaton as used as response values which is described in Section 6.4.1, “Response value serialization”. Not all types are supported for upstream serialization [12] and the capabilities differ also for POST and GET requests. GET upstream serialization is limited to basic types and simple arrays. POST requests on the other support a much large set of types, including the serialization of Maps, Lists and all Open Types. GET request values

Since parameters get encoded in the URL for GET request, only the following types can used for values and arguments in write and exec requests:

  • String
  • Integer / int
  • Long / long
  • Byte / byte
  • Short / short
  • Float / float
  • Double / double
  • BigDecimal / BigInteger
  • char
  • Boolean / boolean
  • Date
  • URL
  • Enums (whose type is accessible to the agent, see below)
  • Any type, that is accessible to the agent, and has a public constructor with one String parameter

The serialized value is simply the string representation of those types. Dates can be set either by an long value (epoch milliseconds) or with a string value (ISO-8601 format). Arrays of the given types are serialized as a comma separated list.

The array support is somewhat limited since it makes a native split on commas. It does not yet take into account any quoting or escaping. For a much safer way to transport arrays to the agent, please consider using POST requests.

Certain tag values are used to mark special values. A null value has to be serialized as [null], an empty String as "". Tag values are not required for POST requests. POST request values

POST request take advantage of the JSON type of the value transfered. These are basic types for numbers (42 or 23.5), booleans (true or false) and strings ("habanero"). Also, JSON knows about null values so no special 'tags' like for GET requests are not required. Since JSON supports intrinsically key-value maps and array types, these can be used directly, too. I.e. if the JMX operation to execute takes a Map argument, the argument can be given as a JSON object. Be aware, however, that JSON maps (objects) only support strings as keys.

The agent knows how to convert an JSON array to Java Arrays (of a basic type) or Lists, depending on the requirement as dictated by the MBeans operation or attribute signature. Numbers in JSON are always transfered as long or double values and are as well tried to fit to the MBean's signature. In case of an overflow (e.g. when trying to treat a long with a too large value as int), an exception is raised.

Enums can be converted from their canonical name. The prerequisite for this is, that the Jolokia agent has access to the Enum's class. This is true for all Enums shipped with the JDK (like TimeUnit). Custom enums can not be used for upstream serialization by default since the Jolokia Agent is not able to contruct an instance of it because of missing type information.

Upstream serialization also supports OpenTypes. If the signature of JMX exec operation or the value type of a JMX attribute is a OpenType, they are serialized as follows:

  • SimpleTypes are extracted from their corresponding JSON type.
  • ArrayType is extracted from a JSONArray where the elements are serialized recursively with this algorithms. Only ArrayTypes with element type CompositeType or SimpleType are supported.
  • CompositeType is extracted recursively from a JSONObject where there the string keys must fit to the CompositeType's item names and the values must be serializable as open types.
  • TabularType is converted from JSONObject. If it is single index (i.e. has only one single index name), the JSONObject must have the index values as string keys and the map values are other JSONObjects representing the row data. For TabularTypes with more than one index name, the incoming JSONObjecct must be a nested object with each index as an additional layer. E.g. the following JSON object works for a TabularType with the two index names lastname and firstname, which are both of type SimpleType.STRING:

      "Mann": {
               "Thomas": {
                          "lastname": "Mann",
                          "firstname": "Thomas",
                          "birth": 1875
               "Heinrich": {
                            "lastname": "Mann",
                            "firstname": "Heinrich",
                            "birth": 1871

    TabularType used by the MXBean framework for serialization of Maps are translated directly from maps. More details are explained in the next section Section 6.4.3, “Jolokia and MXBeans”.

    TabularTypes with index values which are not of type SimpleType can be used, too. However, in this case this simple nested map structure is not enough, since keys of complex types (e.g. CompositeData types) can not be represented as JSON map keys. Instead, a generic representation for TabularTypes must be used. A JSON object with two keys: indexNames with an array of the index names and values with an array of rows containing objects which include the index values plus any other values of the rows' CompositeType. E.g. if in the example above, the index would have been an User with first- and lastname, the JSON structure for setting the TabularData should look like

      "indexNames": [ "user" ],
      "values" : [
         { "user" : { "lastname": "Mann", "firstname": "Thomas" }, "birth": 1875 },
         { "user" : { "lastname": "Mann", "firstname": "Heinrich" }, "birth": 1871 }

6.4.3. Jolokia and MXBeans

The MXBean Framework is availale in the JRE since version 6 and allows for easy creation and registration of own MBeans. MXBeans are some what the successor for standard MBeans and support an annotation driven as well as a naming convention driven programming model. The most important difference to standard MBeans it the restriction of MXBean to reference only open types.

Although to the outside only open types are exposed by the MXBean framework, MXBean themselves can use more complex data types. The framework will translate forth and back between the custom and open types according to certain rules as declared in the MXBean specification. Most of the translations to open types fits naturally to Jolokia's serialization, except for the translation of Map.

When an MXBean references a map, the MXBean framework translates this map into a TabularData with a fixed internal structure, i.e. with an index key and rows with keys key and value. This leads directly to a JSON representation which is quite artificial. E.g a map with two keys kind and hotness will be converted by the MXBean framework to a TabularData object which in turn would be translated by Jolokia to the following JSON struture

  "kind" : {
             "key": "kind",
             "value": "Habanero"
  "hotness" : {
                "key": "hotness",
                "value": 10

Since this representation of a simple map is unnecessarily complicated, Jolokia treats TabularData of this kind (i.e. one index key and rows with properties key and value) specially in order to translate it back (and forth) to

  "kind" : "Habanero",
  "hotness" : 10

6.5. Tracking historical values

The Jolokia agents are able to keep requested values in memory along with a timestamp. If history tracking is switched on, then the agent will put the list of historical values specific for this request into the response. History tracking is toggled by an MBean operation on a Jolokia-owned MBean (see Chapter 7, Jolokia MBeans). This has to be done individually for each attribute or JMX operation to be tracked.

A history entry is contained in every response for which history tracking was switched on. A certain JMX operation on an Jolokia specific MBean has to be executed to turn history tracking on for a specific attribute or operation. See Chapter 7, Jolokia MBeans for details.The history property of the JSON response contains an array of json objects which have two attributes: value containing the historical value (which can be as complex as any other value) and timestamp indicating the time when this value was current (as measured by the server). Example 6.2, “JSON Response” has an example of a response containing historical values.

For multi attribute read requests, the history entry in the response is a JSON object instead of an array, where this object's attributes are the request's attribute names and the values are the history arrays as described above.

6.6. Proxy requests

For proxy requests, POST must be used as HTTP method so that the given JSON request can contain an extra section for the target which should be finally reached via this proxy request. A typical proxy request looks like

    "type" : "read",
    "mbean" : "java.lang:type=Memory",
    "attribute" : "HeapMemoryUsage",
    "target" : {
         "url" : "service:jmx:rmi:///jndi/rmi://targethost:9999/jmxrmi",
         "user" : "jolokia",
         "password" : "s!cr!t"

url within the target section is a JSR-160 service URL for the target server reachable from within the proxy agent. user and password are optional credentials used for the JSR-160 communication.

6.7. Agent Discovery

Jolokia agents are able to respond to certain multicast requests in order to allow clients to detect automatically connection parameters. The agent URL to expose can be either manually configured for an agent or an agent can try to detect its URL automatically. This works fine for the JVM agent, for the WAR agent it only works after the first HTTP request has been processed by the agent. Due to limitations of the Servlet API the agent servlet has no clue about its own URL until this first request, which contains the request URL. Of course, the URL obtained that way can be bogus as well, since the agent might hide behind a proxy, too. So, if in doubt you should configure the agent URL from outside to allow external clients to be discovered. The configuration options for enabling multicast requests are described in the Table 3.6, “JVM agent configuration options” and Table 3.1, “Servlet init parameters” agent configuration sections.

A agent which is enabled for multicast discovery will only respond to a multicast request if the Section 4.1, “Policy based security” allows connections from the source IP. Otherwise a multicast request will be simply ignored. For example, if you have configured your agent to only allow request from a central monitoring host, only this host is able to detect these agents. Beside security aspects it wouldn't make sense to expose the URL as any other host is not able to connect anyways.

Starting with version 1.2.0 the Jolokia JVM agent has this discovery feature enabled by default which can be switched off via --discoveryEnabled=true command line parameter or the corresponding configuration option. For the WAR agent and OSGi agents this feature is switched off by default since auto detection doesn't work always. It can be enabled with the init parameter discoveryEnabled (in which case the auto discovery described above is enabled) or better with discoveryAgentUrl with the URL. Alternatively, a system property can be used with a jolokia. prefix (e.g. jolokia.discoveryEnabled). More on the configuration options can be found in the agent's configuration sections.

For sending a multicast request discovery message, an UDP message should be send to the address, port 24884 which contains a JSON message encoded in UTF-8 with the following format

    "type": "query"

Any agent enabled for discovery will respond to requester on the same socket with an answer which looks like

    "type": "response",
    "agent_description" : "Atlantis Tomcat",
    "agent_id" : "",
    "url": "",
    "server_vendor" : "Apache",
    "server_product" : "Tomcat",
    "server_version" : "7.0.35"

The response itself is a JSON object and is restricted to 8192 bytes maximum. The request type is either query or response. A query request is sent via multicast by any interested client and each agent responds with a response of type response. Query requests contain only the type as property. Responses are sent back to the address and port of the sender of the query request.

Please note, that IPv6 is currently not supported yet but likely in the future.

Table 6.10. Response properties

Property Description Example
type Request type, either query or response. query or response
agent_id Each agent has a unique id which can be either provided during startup of the agent in form of a configuration parameter or being autodetected. If autodected, the id has several parts: The IP, the process id, hashcode of the agent and its type. This field will be always provided.
agent_description An optional description which can be used as a UI label if given. ServiceMix ESB
url The URL how this agent can be contacted. This URL is typically autodetected. For the JVM agent it should be highly accurate. For the servlet based agents, it depends. If configured via an initialisation parameter this URL is used. If autodetected it is taken from the first HTTP request processed by the servlet. Hence no URL is available until this first request was processed. This property might be empty.
secured Whether the agent was configured for authentication or not. false
server_vendor The vendor of the container the agent is running in. This field is included if it could be automatically detected. Apache
server_product The container product if detected tomcat
server_version The container's version (if detected) 7.0.50

6.8. Jolokia protocol versions

The protocol definition is versioned. It contains of a major and minor version. Changes in the minor version are backward compatible to other protocol with the same major version. Major version changes incorporate possibly backwards incompatible changes. This document describes the Jolokia protocol version 7.2.

7.2 (since 1.2.2)

Pathes can now be used with wildcards (*) which match everything in the selected level. They are especially useful with pattern read requests.

7.1 (since 1.2.0)

The version command returns now the configuration global information as well with the key config in the returned value.

7.0 (since 1.1.0)

The maxDepth parameter (either as processing parameter or as configuration value) is now 1 based. I.e. 0 means always "no limit" (be careful with this, though), 1 implies truncating the value on the first level for READ request. This was already true for LIST requests and the other limit values (maxCollectionSize and maxObjects) so this change is used in order to harmonize the overall behaviour with regard to limits.

Enums are now serialized downstream (full support) and upstream (for type accessible to the agent).

New query parameter options serializeException (for setting an error_value in case of an exception), canonicalNaming (influences how object names are returned) and includeStackTrace (for adding or omitting stacktraces in error responses).

6.1 (since 1.0.2)

Error responses contain now the original request as well, for single and bulk requests.

6.0 (since 1.0.0)

Escaping has been changed from /-/ to !/. This affects GET Urls and inner paths.

5.0 (since 0.95) is serialized differently when generating the response. In fact, the serialization as an array in the former versions of this protocol is not correct, since TabularData in fact is a hash and not a list. It is now generated as map (or multiple maps), depending on the declared index. Also, access via path is now an access via key, not a list index. For the special case of MXBean map serialization, where the returned TabularData has a fixed format (i.e. with key and value columns), the TabularData is transformed to an appropriate map..

Removed JSON property modified from the serialized JSON representation of a File return value since it duplicated the lastModified property on the same object.

4.3 (since 0.91)

The list operation supports a maxDepth option for truncating the answer.

4.2 (since 0.90)

Response values are returned in the native JSON datatype, not always as strings as in previous versions of this protocol. Parameter serialization for writing attribute values or for arguments in exec operations has been enhanced for POST requests, which are now represented as native JSON types and not in a string representation as before. GET requests still use a simplified string representation.

4.0 (17.10.2010)

This is the initial version for Jolokia. Versions below 4 are implemented by jmx4perl

[7] This document will avoid the term REST as much as possible in order to avoid provoking any dogmatic resentments.

[8] A backslash (\) can not be used, since most servlet container translate a backslash into a forward slash on the fly when given in an URL.

[9] Seconds since 1.1.1970

[10] If the server exception is a subtype of MBeanException, the wrapped exception's message is used.

[11] For JBoss older than version 7, there might be use cases when custom enums need to be serialized. In this case, the type information must be available to the agent, too. For the standard PlatformMBeanServer serialization should work always, regardless whether the customer enum type is accessible by the agent or not.

[12] Conversion from a typed system to an untyped representation is obviously much easier than vice versa. Please note, that Jolokia does not replace a full blown JSON object serialization framework like Jackson. Nor does it use one in order to keep the agent small and simple with a low dependency count.