<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Jolokia on Roland Huß</title><link>https://ro14nd.de/tags/jolokia/</link><description>Recent content in Jolokia on Roland Huß</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 Roland Huß</copyright><lastBuildDate>Thu, 03 Nov 2016 00:00:00 +0000</lastBuildDate><atom:link href="https://ro14nd.de/tags/jolokia/index.xml" rel="self" type="application/rss+xml"/><item><title>Why Jolokia is not RESTful</title><link>https://ro14nd.de/jolokia-is-not-rest/</link><pubDate>Thu, 03 Nov 2016 00:00:00 +0000</pubDate><guid>https://ro14nd.de/jolokia-is-not-rest/</guid><description>&lt;p&gt;From time to time people come to me and say: &amp;ldquo;I really would love Jolokia if only it would be RESTful&amp;rdquo;. This post tells you why.&lt;/p&gt;
&lt;p&gt;I really like REST, yes I do.
If I would crete a new application on a green field, its remote access API would very likely obey the REST paradigm.&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;However, &lt;a href="https://www.jolokia.org" target="_blank" rel="noreferrer"&gt;Jolokia&lt;/a&gt; is a different beast.
It is a bridge to the world of JMX, providing an open minded alternative to the rusty and Java specific JSR-160 standard.
Its protocol is based on JSON over HTTP, so in principle it could be REST.
But it is not, mainly for the following two reasons:&lt;/p&gt;

&lt;h3 class="relative group"&gt;JMX resource naming is a mess
 &lt;div id="jmx-resource-naming-is-a-mess" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#jmx-resource-naming-is-a-mess" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;Jolokia doesn&amp;rsquo;t not have any influence on the naming of the resources it accesses.
These resources are JMX &lt;a href="https://docs.oracle.com/javase/tutorial/jmx/mbeans/" target="_blank" rel="noreferrer"&gt;MBeans&lt;/a&gt; and their identifiers are &lt;a href="http://docs.oracle.com/javase/8/docs/api/javax/management/ObjectName.html" target="_blank" rel="noreferrer"&gt;ObjectNames&lt;/a&gt;.
ObjectNames have a certain structure but beside this they can be named arbitrarily.
So if you want to provide an HTTP API for accessing these repositories, this free form addressing poses some challenges, especially for read operations with &lt;code&gt;GET&lt;/code&gt;.
For example it is impossible to transmit a slash (&lt;code&gt;/&lt;/code&gt;) or backslash (&lt;code&gt;\\&lt;/code&gt;) as part of an URL&amp;rsquo;s path info.
The reason is &lt;a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0450" target="_blank" rel="noreferrer"&gt;security related&lt;/a&gt;, and each application server handles this differently: Tomcat for example completely rejects such requests whereas Wildfly / Undertow &lt;a href="https://issues.jboss.org/browse/UNDERTOW-879" target="_blank" rel="noreferrer"&gt;refuses&lt;/a&gt; to URL decode &lt;code&gt;%2F&lt;/code&gt; (for &lt;code&gt;/&lt;/code&gt;) and &lt;code&gt;%5C&lt;/code&gt; for &lt;code&gt;\\&lt;/code&gt;.
Jetty doesn&amp;rsquo;t care much.
So in order to address a JMX MBean which contains these characters as part of their names, the typical encoding as part of an URL path doesn&amp;rsquo;t work.
One could use query parameters for this kind of addressing and in fact, Jolokia &lt;a href="https://jolokia.org/reference/html/protocol.html#get-request" target="_blank" rel="noreferrer"&gt;supports&lt;/a&gt; this, too.
But it&amp;rsquo;s still ugly.
Also, implementers of MBeans tend to put semantic information into the MBean name like the port of a connector or the name of a database scheme.
It can&amp;rsquo;t excluded that the MBean name alone can carry sensitive information.
However GET urls are &lt;em&gt;not&lt;/em&gt; secured via the transport protocol and tend to end up in log files.
So, its much safer to send these requests via POST, even when only performing read operations on JMX attributes.&lt;/p&gt;

&lt;h3 class="relative group"&gt;Bulk requests
 &lt;div id="bulk-requests" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#bulk-requests" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;A special feature of Jolokia are &lt;a href="https://jolokia.org/reference/html/protocol.html#post-request" target="_blank" rel="noreferrer"&gt;Bulk Requests&lt;/a&gt;.
This allows a very efficient monitoring of multiple values with a single HTTP request.
It works by sending a list of individual, JSON encoded Jolokia requests with a single HTTP &lt;code&gt;POST&lt;/code&gt; request.
That list can contain any valid Jolokia operation:
Reading and writing attributes, executing some operations, searching for or listing of MBeans.
The heterogenous nature of this kind of requests makes it hard to map them to one single HTTP verb as REST suggests.
Also, the sheer length of the request parameter forbids to send a bulk request via GET as Servlet container or other application servers impose certain restrictions on the length of an URL, which vary however from server to server.&lt;/p&gt;

&lt;h3 class="relative group"&gt;Jolokia implements both
 &lt;div id="jolokia-implements-both" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#jolokia-implements-both" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;For every Jolokia operation, we play both: GET and POST &lt;sup id="fnref:2"&gt;&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref"&gt;2&lt;/a&gt;&lt;/sup&gt;.
As an integration tool, which helps to bridge different worlds without really having control over these worlds, the focus is on maximal flexibility so that it can adapt to any environment where it is used.
REST is only of second importance here, but if you think the issues described above can be solved in a more RESTful way, I&amp;rsquo;m more than open.&lt;/p&gt;
&lt;div class="footnotes" role="doc-endnotes"&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id="fn:1"&gt;
&lt;p&gt;I&amp;rsquo;ve to confess that I&amp;rsquo;m really not a REST expert, so if you don&amp;rsquo;t agree with my arguments, I&amp;rsquo;d kindly ask you to leave a comment or tweet me for corrections.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:2"&gt;
&lt;p&gt;or: &amp;ldquo;Country and Western&amp;rdquo;&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description></item><item><title>Java EE Management is dead</title><link>https://ro14nd.de/java-management-is-dead/</link><pubDate>Mon, 10 Oct 2016 00:00:00 +0000</pubDate><guid>https://ro14nd.de/java-management-is-dead/</guid><description>&lt;p&gt;Now that some weeks has been passed we all had time to absorb the &lt;a href="https://java.net/downloads/javaee-spec/JavaEE8Update.pdf" target="_blank" rel="noreferrer"&gt;revised Java EE 8 proposal&lt;/a&gt; presented at Java One. As you know, some JSRs remained, some things were added and some stuff was dropped. &lt;a href="https://www.jcp.org/en/jsr/detail?id=373" target="_blank" rel="noreferrer"&gt;Java EE Management API 2.0&lt;/a&gt;, supposed to be a modern successor of JSR 77, is one of the three JSRs to be dropped.&lt;/p&gt;
&lt;p&gt;What does this mean for the future of Java EE management and monitoring ?&lt;/p&gt;
&lt;p&gt;First of all it&amp;rsquo;s fair to state that &lt;a href="https://www.jcp.org/en/jsr/detail?id=373" target="_blank" rel="noreferrer"&gt;JSR 373&lt;/a&gt; never really took off. Since February 2015 there were not more than &lt;a href="https://java.net/projects/javaee-mgmt/lists/jsr373-experts/archive" target="_blank" rel="noreferrer"&gt;86 mails&lt;/a&gt; on the expert group mailing list, half of them written in March 2015 during incubation. At the latest of January 2016 it was clear that JSR-373 &lt;a href="https://java.net/projects/javaee-mgmt/lists/jsr373-experts/archive/2016-01/message/2" target="_blank" rel="noreferrer"&gt;is not on Oracle&amp;rsquo;s focus anymore&lt;/a&gt;. To be honest, even we members of the expert group, we were not able to push this JSR further.&lt;/p&gt;
&lt;p&gt;How did it come that far ? Let&amp;rsquo;s have a look back into history.&lt;/p&gt;
&lt;p&gt;All starts with &lt;a href="https://jcp.org/en/jsr/detail?id=3" target="_blank" rel="noreferrer"&gt;JSR 3&lt;/a&gt; back in 1999. This first JMX specification is the foundation of all Java resources management. As it can been seen by its age, Java folks took care about Management and Monitoring from the very beginning on. And even better, since &lt;a href="http://docs.oracle.com/javase/1.5.0/docs/guide/management/index.html" target="_blank" rel="noreferrer"&gt;JS2E 5&lt;/a&gt; JMX is integral part of Java SE so its available on every JVM out there.&lt;/p&gt;
&lt;p&gt;Over the years, additional JSRs were added on top of this base:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://jcp.org/en/jsr/detail?id=160" target="_blank" rel="noreferrer"&gt;JSR 160&lt;/a&gt; defines a remote protocol for JMX,, which is based on &lt;a href="http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136424.html" target="_blank" rel="noreferrer"&gt;RMI&lt;/a&gt;. This might have been a good decision in 2003, but turned out to be awful to use especially for non-Java based monitoring systems.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jcp.org/en/jsr/detail?id=262" target="_blank" rel="noreferrer"&gt;JSR 262&lt;/a&gt; was started to overcome this by defined a &amp;ldquo;WebServices Connector for Java Management Extensions Agents&amp;rdquo; which was mostly around SOAP services. However although even an initial implementation existed, it was withdrawn before the final release. It&amp;rsquo;s not completely clear why it was stopped in 2008 and later withdrawn, as the &lt;a href="https://jcp.org/en/jsr/results?id=4548" target="_blank" rel="noreferrer"&gt;public review ballot has been approved&lt;/a&gt;, although it was a tight result. The biggest objections were on dependencies on &amp;ldquo;proprietary&amp;rdquo; WS-* specifications.&lt;/li&gt;
&lt;li&gt;&amp;ldquo;J2EE Management&amp;rdquo; &lt;a href="https://jcp.org/en/jsr/detail?id=77" target="_blank" rel="noreferrer"&gt;JSR 77&lt;/a&gt; was finished in 2002 and defines a hierarchy how Management and Monitoring resources exposed by a Java EE server is structured. It allows a uniform interface for how to access the various Java EE resources, like web applications or connector pools. Beside this it also defines how statistics are exposed by defining various metrics formats. However, implementing the &lt;code&gt;StatisticsProvider&lt;/code&gt; model is not mandatory and from my personal experience it was implemented only rarely by some vendors and if so, not for every resource.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jcp.org/en/jsr/detail?id=88" target="_blank" rel="noreferrer"&gt;JSR 88&lt;/a&gt; complements JSR 77 and defines a common format for deploying Java EE artefacts.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jcp.org/en/jsr/detail?id=255" target="_blank" rel="noreferrer"&gt;JSR 255&lt;/a&gt; was started to be the next version of JMX and supposed to be included in Java 7. Although it was already nearly finished and integrated, &lt;a href="https://community.oracle.com/blogs/emcmanus/2009/06/16/jsr-255-jmx-api-20-postponed" target="_blank" rel="noreferrer"&gt;it didn&amp;rsquo;t make it into Java 7&lt;/a&gt; (nor Java 8). The spec was then dormant until it was finally withdrawn in 2016.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With the dead of JMX 2.0 in 2009 the evolution of JMX as a standard for Java SE has stalled. But what&amp;rsquo;s about Java EE Management ? At least JSR 77 is still part of Java EE 7 and for Java EE 8 the successor was supposed to be JSR 373. JSR 373 tackles the problem of remote access, whereas JSR 77 still relies on RMI as a standard implementation protocol as defined in JSR 160.&lt;/p&gt;
&lt;p&gt;The two major goals of JSR 373 were:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Provide an update of the hierarchal resource and statistics structure as defined by JSR 77&lt;/li&gt;
&lt;li&gt;Provide a REST access to these resources independent of JMX&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the often cited &lt;a href="https://java.net/downloads/javaee-spec/JavaEE8_Community_Survey_Results.pdf" target="_blank" rel="noreferrer"&gt;Java EE 8 Community Survey&lt;/a&gt; more than 60% were in favour of defining a new API for managing application, which should be based on REST (83% pro-votes). This finally lead to JSR 373. However, as it seems in retrospective, a deep interest in this topic was not really given and probably lead to this final decision to drop JSR 373 from Java EE 8.&lt;/p&gt;
&lt;p&gt;So, what is the state of Monitoring and Management of Java and in particular Java EE applications nowadays and what can be expected in the future ? Let&amp;rsquo;s have a look into the crystal ball.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;JMX is here to stay&lt;/strong&gt;. It is part of Java SE and I don&amp;rsquo;t know of any plans for removing it from future Java editions. Ok, it feels a bit rusty but it is still rock solid and gives you deep insight in the state of your JVM. With tools like &lt;a href="https://jolokia.org/" target="_blank" rel="noreferrer"&gt;Jolokia&lt;/a&gt; you can overcome most of the restrictions JSR 160 imposes. (Disclaimer: since I&amp;rsquo;m the author of Jolokia all my personal opinions given here should be evaluated in this light :)&lt;/li&gt;
&lt;li&gt;It is not clear how the Management API of Java EE 8 and beyond looks like. It does not look like that JSR 77 will survive. Will there be a standard for Java EE management at all ? Probably not, and so there is the danger that vendors will push their proprietary management APIs, which already &lt;a href="https://docs.jboss.org/author/display/WFLY10/The&amp;#43;HTTP&amp;#43;management&amp;#43;API" target="_blank" rel="noreferrer"&gt;happens&lt;/a&gt; to some extent. Luckily, most of these proprietary APIs are also mirrored in JMX these days.&lt;/li&gt;
&lt;li&gt;On the other hand, it could be also a good thing that there is no other Management API which is not based on JMX. That&amp;rsquo;s because you will always need JMX to monitor the basic aspects like Heap Memory usage or Thread count, which are covered by Java SE. Adding a different, REST like protocol for Java EE monitoring requires operators to access a Java EE server with two different protocols (JMX &lt;strong&gt;and&lt;/strong&gt; Rest), duplicating configuration efforts on the monitoring side. This can only be avoided if the &lt;a href="https://java.net/projects/javaee-mgmt/lists/jsr373-experts/archive/2016-06/message/1" target="_blank" rel="noreferrer"&gt;Java EE resources are mirrored in JMX&lt;/a&gt;, too.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To sum it up, I think its a shame that Management and Monitoring, which played a prominent role over the whole evolution of Java EE, will probably be dropped completely in Java EE 8. As a replacement the new &lt;a href="https://java.net/downloads/javaee-spec/JavaEE8Update.pdf" target="_blank" rel="noreferrer"&gt;Health Check&lt;/a&gt; API has been announced, but to be honest, that can&amp;rsquo;t be a full replacement for classical management and monitoring where the evaluation of a system&amp;rsquo;s health is done on a dedicated monitoring platform (e.g. like Nagios or Prometheus). These platforms take the plain metrics data exposed by the application and does the data evaluation on their own.&lt;/p&gt;
&lt;p&gt;The good thing is still that you have JMX to the rescue and I&amp;rsquo;m pretty sure that this technology will survive also this storm. Especially if vendors are willing to support it for their application server metrics, too.&lt;/p&gt;
&lt;p&gt;Even without a Java EE standard.&lt;/p&gt;</description></item><item><title>Jolokia 2.0 - JMX Notifications</title><link>https://ro14nd.de/jolokia-notifications/</link><pubDate>Wed, 13 Jan 2016 00:00:00 +0000</pubDate><guid>https://ro14nd.de/jolokia-notifications/</guid><description>&lt;p&gt;This screencast gives a live demo of the forthcoming JMX notification support in Jolokia 2.0.&lt;/p&gt;
&lt;iframe src="https://player.vimeo.com/video/151629488" width="720" height="405" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen&gt;&lt;/iframe&gt;
&lt;p&gt;Jolokia supports currently two notification modes. In all modes, the Jolokia agent itself subscribe to a JMX notification locally and then dispatches the notifications to its clients.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pull Mode&lt;/strong&gt; : Here, the agent keeps the notification received for a client in memory and sends it back on an JMX request to a Jolokia specific MBean. A client typically queries this notification MBean periodically.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SSE Mode&lt;/strong&gt; : &lt;a href="http://www.w3.org/TR/2011/WD-eventsource-20110208/" target="_blank" rel="noreferrer"&gt;Server Sent Events&lt;/a&gt; are a W3C standard for pushing events from an HTTP server to a client. With this mode the Jolokia agents directly pushes any notification it receives to the client. The advantage is of course a much lower latency compared to the pull mode, but SSE is &lt;a href="http://caniuse.com/#feat=eventsource" target="_blank" rel="noreferrer"&gt;not available for Internet Explorer&lt;/a&gt;, including 11. What a pity.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href="https://jolokia.org/reference/html/protocol.html" target="_blank" rel="noreferrer"&gt;Jolokia protocol&lt;/a&gt; has been extended with the top level action &lt;code&gt;notification&lt;/code&gt; and subcommands.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;register&lt;/code&gt; / &lt;code&gt;unregister&lt;/code&gt; : Register / unregister a notification client&lt;/li&gt;
&lt;li&gt;&lt;code&gt;add&lt;/code&gt; / &lt;code&gt;remove&lt;/code&gt; : Add / remove a listener subscription&lt;/li&gt;
&lt;li&gt;&lt;code&gt;list&lt;/code&gt; : list all subscriptions for a client&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ping&lt;/code&gt; : Keep subscription alive&lt;/li&gt;
&lt;li&gt;&lt;code&gt;open&lt;/code&gt; : Use for creating a back channel. E.g. the &lt;em&gt;SSE&lt;/em&gt; mode keeps this GET request for pushing back an event stream.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Currently only the new Jolokia JavaScript client supports JMX notification. If you are interested in having it in other clients (e.g. Java), too, please let me know. I would be more than happy for coders jumping on the Jolokia bandwagon since there is still quite some stuff to do for 2.0.&lt;/p&gt;
&lt;p&gt;The source code to this demo and the new Jolokia JavaScript client is on GitHub: &lt;a href="https://github.com/jolokia-org/jolokia-client-javascript" title="https://github.com/jolokia-org/jolokia-client-javascript" target="_blank" rel="noreferrer"&gt;https://github.com/jolokia-org/jolokia-client-javascript&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Welcome to 2016 - the year Jolokia 2.0 will see the light of day</title><link>https://ro14nd.de/jolokia-in-2016/</link><pubDate>Wed, 06 Jan 2016 00:00:00 +0000</pubDate><guid>https://ro14nd.de/jolokia-in-2016/</guid><description>&lt;p&gt;I hope you all had a good start into 2016 and have charged all your batteries during the time of stillness.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.jolokia.org" target="_blank" rel="noreferrer"&gt;Jolokia&lt;/a&gt; had a good start, too. During the holiday season I took the opportunity to continue to work on version 2.0 which now takes on form. If you have followed the history of Jolokia you know that work on 2.0 started early 2013 but advanced quite slowly for multiple reasons.&lt;/p&gt;
&lt;p&gt;Now its time to go out on a limb with announcing Jolokia 2.0 for 2016. A bit of pressure sometimes really helps ;-)&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s are the major themes for Jolokia 2.0:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Jolokia 2.0 will be &lt;strong&gt;backwards compatible&lt;/strong&gt; on the protocol level. This is a design goal. There might be some changes in default values, however this should be easy to fix. Any such change will be announced prominently (like artefact renaming). So, all your clients will be usable with 2.0 with minor changes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JMX Notification&lt;/strong&gt; support is here. Yeah, this was quite some work. The extensions to the Jolokia 2.0 protocol are able to push notifications in various ways. Currently the agents supports two modes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pull mode&lt;/strong&gt; will collect JMX notification on the server (agent) side and can be fetched by a client with an HTTP request, which typically happens periodically. This introduces some latencies but is the most robust way to transmit notifications to a client.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SSE mode&lt;/strong&gt; uses &lt;a href="http://www.w3.org/TR/2011/WD-eventsource-20110208/" target="_blank" rel="noreferrer"&gt;Server Sent Events&lt;/a&gt; for pushing JMX notifications immediately with very low latency. This is the preferred mode if a client supports this (Internet Explorer does not).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The notification support is nearly complete on the agent side, and the Jolokia JavaScript client already supports both modes. In the future more mode like WebSockets or Web-Hooks should be easy to add. The next post will give a demo about the notification support.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Namespaces&lt;/strong&gt; extend Jolokia beyond JMX which means you can access other entities than JMX MBeans with the very same protocol. This feature is still in the conceptual state but one can easily imagine to access&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Spring Beans&lt;/li&gt;
&lt;li&gt;CDI Objects&lt;/li&gt;
&lt;li&gt;JNDI Directories&lt;/li&gt;
&lt;li&gt;Zookeeper Directories&lt;/li&gt;
&lt;li&gt;&amp;hellip;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;the same was as JMX. The namespace is selected as part of the (MBean) name. More on this in this &lt;a href="https://github.com/rhuss/jolokia/wiki/Requesthandler" target="_blank" rel="noreferrer"&gt;design document&lt;/a&gt;. Since this feature would extend the usage pattern of Jolokia quite a bit, I&amp;rsquo;m not 100% sure whether to include it into 2.0 since it feels a bit against my Unix based education (&amp;ldquo;do one thing and do it well&amp;rdquo;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;With the addition of even more features, &lt;strong&gt;modularization&lt;/strong&gt; becomes even more important. Jolokia was and is always picky about its footprint, which is currently 430k for the WAR agent with all features included. Jolokia 2.0 introduces various &lt;a href="https://github.com/rhuss/jolokia/wiki/Jolokia-Services" target="_blank" rel="noreferrer"&gt;internal services&lt;/a&gt; which can be picked and chosen by repackaging the agent. Or the agent can be extended with own functionality, too. A way for easily packaging and creating agents will be provided either by a Web-UI or by a CLI tool (or both).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition there are also some non-functional changes to polish Jolokia a bit:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Non-agent based addition like client libraries, integration tests, JBoss Forge support are extracted into extra GitHub repositories. All this will happen within the GitHub organization &lt;a href="https://github.com/jolokia-org" target="_blank" rel="noreferrer"&gt;jolokia-org&lt;/a&gt;. The first project here is the JavaScript client which already moved to a dedicated &lt;a href="https://github.com/jolokia-org/jolokia-client-javascript" target="_blank" rel="noreferrer"&gt;jolokia-client-javascript&lt;/a&gt; repository.&lt;/li&gt;
&lt;li&gt;The website will get a face-lift.&lt;/li&gt;
&lt;li&gt;Documentation will switch from Docbook to a Markdown or AsciiDoc based format.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Finally some stuff will get dropped. This happens because of limited resources (Jolokia, to be frankly, still doesn&amp;rsquo;t have a big community, so that most of the work is done by a single person. &amp;lsquo;would like to change that, though) and because I think these feature never took off:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mule agent&lt;/strong&gt;. I never got much feedback from the Mule community so I&amp;rsquo;m really not sure whether this agent is really used or needed. Jolokia 1.x will continue to support the Mule agent, however there will be no stock Jolokia 2.0 Mule agent. Said that, you are always free to adopt Jolokia 2.0 to the Mule management platform. Considering the extra code needed included in Jolokia 1.3 for Mule support this should be fairly trivial. I&amp;rsquo;m happy to support anyone doing the port. Also, there is always the alternative to use the JVM agent for attaching Jolokia to Mule, which is the preferred way for 2.0 to monitor Mule with Jolokia.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Spring Roo Support&lt;/strong&gt; will be dropped for much the same reasons. I never received an issue on the Jolokia Spring Roo support, which is a clear sign that nobody is using it. It might popup as an extra project.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, what&amp;rsquo;s the roadmap ? Here&amp;rsquo;s the plan:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Milestone 2.0.0-M1 is here. You find the &lt;a href="http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-agent-jvm/2.0.0-M1/jolokia-agent-jvm-2.0.0-M1-agent.jar" target="_blank" rel="noreferrer"&gt;JVM&lt;/a&gt; and &lt;a href="http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-agent-war/2.0.0-M1/jolokia-agent-war-2.0.0-M1.war" target="_blank" rel="noreferrer"&gt;WAR&lt;/a&gt; agents in Maven central.&lt;/li&gt;
&lt;li&gt;Every month, a new milestone will be released.&lt;/li&gt;
&lt;li&gt;Final release is aligned to &lt;a href="http://www.redhat.com/summit/" target="_blank" rel="noreferrer"&gt;Red Hat Summit&lt;/a&gt; / &lt;a href="http://www.devnation.org/" target="_blank" rel="noreferrer"&gt;DevNation&lt;/a&gt;. July 1st.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Isn&amp;rsquo;t this a nice new year&amp;rsquo;s resolution ? ;-)&lt;/p&gt;
&lt;p&gt;In the next post I will demo JMX notifications and how you can use them in your JavaScript projects.&lt;/p&gt;</description></item><item><title>Jmx4Perl for everyone</title><link>https://ro14nd.de/jmx4perl-docker/</link><pubDate>Tue, 28 Jul 2015 00:00:00 +0000</pubDate><guid>https://ro14nd.de/jmx4perl-docker/</guid><description>&lt;p&gt;As you might know, &lt;a href="http://www.jmx4perl.org" target="_blank" rel="noreferrer"&gt;Jmx4Perl&lt;/a&gt; is the mother of &lt;a href="https://jolokia.org/" target="_blank" rel="noreferrer"&gt;Jolokia&lt;/a&gt;. But what might be not so known is, that Jmx4Perl provides a set of nice CLI tools for accessing Jolokia agents. However, installing Jmx4Perl manually is cumbersome because of its many Perl and also native dependencies.&lt;/p&gt;
&lt;p&gt;However, if you are a Docker user there is now a super easy way to benefit from this gems.&lt;/p&gt;
&lt;p&gt;Even if Perl is not your cup of tea, you might like the following tool (for which of course no Perl knowledge is required at all):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://search.cpan.org/~roland/jmx4perl/scripts/jmx4perl" target="_blank" rel="noreferrer"&gt;&lt;strong&gt;jmx4perl&lt;/strong&gt;&lt;/a&gt; is a command line tool for one-shot querying Jolokia agents. It is perfectly suited for shell scripts.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://search.cpan.org/~roland/jmx4perl/scripts/j4psh" target="_blank" rel="noreferrer"&gt;&lt;strong&gt;j4psh&lt;/strong&gt;&lt;/a&gt; is a readline based, JMX shell with coloring and command line completion. You can navigate the JMX namespace like directories with &lt;code&gt;cd&lt;/code&gt; and &lt;code&gt;ls&lt;/code&gt;, read JMX attributes with &lt;code&gt;cat&lt;/code&gt; and execute operations with &lt;code&gt;exec&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://search.cpan.org/~roland/jmx4perl/scripts/jolokia" target="_blank" rel="noreferrer"&gt;&lt;strong&gt;jolokia&lt;/strong&gt;&lt;/a&gt; is an agent management tool which helps you in downloading Jolokia agents of various types (war, jvm, osgi, mule) and versions. It also knows how to repackage agents e.g. for enabling security for the war agent by in-place modification of the web.xml descriptor.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://search.cpan.org/~roland/jmx4perl/scripts/check_jmx4perl" target="_blank" rel="noreferrer"&gt;&lt;strong&gt;check_jmx4perl&lt;/strong&gt;&lt;/a&gt; is a full featured Nagios plugin.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;How can you now use these tools ? All you need is a running Docker installation. The tools mentioned above are all included within the Docker image &lt;a href="https://registry.hub.docker.com/u/jolokia/jmx4perl/" target="_blank" rel="noreferrer"&gt;jolokia/jmx4perl&lt;/a&gt; which is available from Docker Hub.&lt;/p&gt;
&lt;p&gt;Some examples:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Get some basic information of the server
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run --rm -it jolokia/jmx4perl \
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; jmx4perl http://localhost:8080/jolokia
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Download the current jolokia.war agent
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run --rm -it -v `pwd`:/jolokia jolokia/jmx4perl \
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; jolokia
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Start an interactive JMX shell
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# server &amp;#34;tomcat&amp;#34; is defined in ~/.j4p/jmx4perl.config
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run --rm -it -v ~/.j4p:/root/.j4p jolokia/jmx4perl \
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; j4psh tomcat&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;In these examples we mounted some volumes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you put your server definitions into &lt;code&gt;~/.j4p/jmx4perl.config&lt;/code&gt; you can use them by mounting this directory as volume with &lt;code&gt;-v ~/.j4p:/root/.j4p&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For the management tool &lt;code&gt;jolokia&lt;/code&gt; it is recommended to mount the local directory with &lt;code&gt;-v $(pwd):/jolokia&lt;/code&gt; so that downloaded artefacts are stored in the current host directory. (Note for boot2docker users: This works only when you are in a directory below you home directory)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is recommended to use aliases as abbreviations:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;alias jmx4perl=&amp;#34;docker run --rm -it -v ~/.j4p:/root/.j4p jolokia/jmx4perl jmx4perl&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;alias jolokia=&amp;#34;docker run --rm -it -v `pwd`:/jolokia jolokia/jmx4perl jolokia&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;alias j4psh=&amp;#34;docker run --rm -it -v ~/.j4p:/root/.j4p jolokia/jmx4perl j4psh&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;As an additional benefit of using Jmx4Perl that way, you can access servers which are not directly reachable by you. The Jolokia agent must be reachable by the Docker daemon only. For example, you can communicate with a SSL secured Docker daemon running in a DMZ only. From there you can easily reach any other server with a Jolokia agent installed, so there is no need to open access to all servers from your local host directly.&lt;/p&gt;
&lt;p&gt;Finally, here&amp;rsquo;s a short appetiser with an (older) demo showing &lt;code&gt;j4psh&lt;/code&gt; in action.&lt;/p&gt;
&lt;iframe width="720" height="405" src="https://www.youtube.com/embed/y9TuGzxD2To" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description></item><item><title>Jmx4Perl on OS X</title><link>https://ro14nd.de/jmx4perl-on-osx/</link><pubDate>Mon, 23 Mar 2015 00:00:00 +0000</pubDate><guid>https://ro14nd.de/jmx4perl-on-osx/</guid><description>&lt;p&gt;The HTTP-JMX Bridge &lt;a href="http://www.jolokia.org" target="_blank" rel="noreferrer"&gt;Jolokia&lt;/a&gt; allows easy access to JMX. It exposes all JMX information and operations via an REST-like interface and has tons of nifty features. &lt;a href="http://search.cpan.org/~roland/jmx4perl/" target="_blank" rel="noreferrer"&gt;Jmx4Perl&lt;/a&gt; on the other side is a client for Jolokia, which beside Perl access modules also provides quite some nice CLI tools for accessing and installing Jolokia. This post explains how install these tools on OS X.&lt;/p&gt;
&lt;p&gt;Jmx4Perl provides some nice CLI commands:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://search.cpan.org/~roland/jmx4perl/scripts/jmx4perl" target="_blank" rel="noreferrer"&gt;jmx4perl&lt;/a&gt; is a simple access tool which is useful for quick queries and ideal for inclusion in shell scripts.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://search.cpan.org/~roland/jmx4perl/scripts/j4psh" target="_blank" rel="noreferrer"&gt;j4psh&lt;/a&gt; is a powerful interactive, readline based JMX shell with tab completion and syntax highlighting.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://search.cpan.org/~roland/jmx4perl/scripts/jolokia" target="_blank" rel="noreferrer"&gt;jolokia&lt;/a&gt; is a tool for managing Jolokia agents (downloading, changing init properties etc.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All this tools are very helpful in order to explore the JMX namespace and installing the agent. They all are fairly good documented and each of them probably deserves an own blog post.&lt;/p&gt;
&lt;p&gt;However, the installation or Perl modules and programs is a bit tedious. Although &lt;a href="http://search.cpan.org/~andk/CPAN/scripts/cpan" target="_blank" rel="noreferrer"&gt;cpan&lt;/a&gt; helps here and also resolves transitive dependencies it&amp;rsquo;s still a lengthy process, which fails from time to time. Native Linux packages are planned, but don&amp;rsquo;t hold your breath ;-).&lt;/p&gt;
&lt;p&gt;For OS X users with &lt;a href="http://brew.sh/" target="_blank" rel="noreferrer"&gt;Homebrew&lt;/a&gt; can install Jmx4Perl quite easily, though:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ brew install cpanm
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cpanm --sudo install JMX::Jmx4Perl&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This will do all the heavy lifting for you and at the end all the fine Jmx4Perl tools are installed and available under &lt;code&gt;/usr/local/bin&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;j4psh&lt;/code&gt; uses &lt;code&gt;libreadline&lt;/code&gt; for the input handling. For the best user experience GNU ReadLine is recommended. Unfortunately, OS X doesn&amp;rsquo;t ship with a &lt;em&gt;true&lt;/em&gt; &lt;code&gt;libreadline&lt;/code&gt; but with &lt;code&gt;libedit&lt;/code&gt; which is a stripped down version of libreadline. In order to use GNU readline, some tricks are needed which are described in this &lt;a href="http://blogs.perl.org/users/aristotle/2013/07/easy-osx-termreadlinegnu.html" target="_blank" rel="noreferrer"&gt;recipe&lt;/a&gt;. For me, the following steps worked (but are probably a bit &amp;ldquo;dirty&amp;rdquo;):&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ brew install readline
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ brew link --force readline
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo mv /usr/lib/libreadline.dylib /tmp/libreadline.dylib 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cpanm --sudo Term::ReadLine::Gnu
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo mv /tmp/libreadline.dylib /usr/lib/libreadline.dylib
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ brew unlink readline&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;These steps are really only necessary if you need advanced readline functionality (or a coloured prompt in j4psh ;-).&lt;/p&gt;</description></item><item><title>Health Checks with Jolokia</title><link>https://ro14nd.de/health-checks/</link><pubDate>Sat, 17 Jan 2015 00:00:00 +0000</pubDate><guid>https://ro14nd.de/health-checks/</guid><description>&lt;p&gt;A &lt;em&gt;health check&lt;/em&gt; is a useful technique for determining the overall operational state of a system in a consolidated form. It provides some kind of internal monitoring which collects metrics, evaluates them against some thresholds and provides a unified result. Health checks are now coming to &lt;a href="http://www.jolokia.org" target="_blank" rel="noreferrer"&gt;Jolokia&lt;/a&gt;. This post explains the strategy to include health checks into Jolokia without blowing up the agents to much.&lt;/p&gt;
&lt;p&gt;Health checks are different to classical monitoring solutions like Nagios, where external systems collect metrics and evaluate them against some threshold on their own. While monitoring with Nagios was and is always possible with Jolokia (and in fact was the original motivation for creating it), intrinsic health checks were avoided for the vanilla agent up to now because of the extra complexity they introduce into the agent. One of the major design goals of Jolokia is to keep it small and focussed.&lt;/p&gt;
&lt;p&gt;The upcoming release 1.3.0 (scheduled for the end of this month) will introduce a simple plugin architecture into Jolokia which allows to hook into the agent&amp;rsquo;s lifecycle. A so called &lt;a href="https://github.com/rhuss/jolokia/blob/master/agent/core/src/main/java/org/jolokia/backend/plugin/MBeanPlugin.java" target="_blank" rel="noreferrer"&gt;MBeanPlugin&lt;/a&gt; in Jolokia also allows access to the agent configuration and to the JMX system. Currently it is supported for the WAR and JVM agent, where plugins are created via a simple class path lookup. For the OSGi agent it is planned that it will pick up plugins as OSGi services.&lt;/p&gt;
&lt;p&gt;Having this new infrastructure in place, extra functionality like health checks can be added easily. The GitHub repository &lt;a href="https://github.com/rhuss/jolokia-extra" target="_blank" rel="noreferrer"&gt;jolokia-extra&lt;/a&gt; was created to host various extensions to the Jolokia agent, also to keep the original agent as lean as possible. Beside the new health checks there is already an extension &lt;em&gt;jsr77&lt;/em&gt; for simplifying the access to &lt;a href="https://jcp.org/en/jsr/detail?id=77" target="_blank" rel="noreferrer"&gt;JSR-77&lt;/a&gt; compliant JEE Servers like WebSphere.&lt;/p&gt;
&lt;p&gt;The new &lt;a href="https://github.com/rhuss/jolokia-extra/tree/master/addon/health" target="_blank" rel="noreferrer"&gt;health&lt;/a&gt; addon in &lt;em&gt;jolokia-extra&lt;/em&gt; has just been started. Currently it contains not much more as proof-of-concept with some hardcoded health checks, but it already illustrate the concept: A &lt;code&gt;MBeanPlugin&lt;/code&gt; registers a certain &lt;code&gt;SampleHealthCheckMBean&lt;/code&gt; during startup which exposes the health checks as JMX operations (and which can be executed as usual with Jolokia). These operations have access to JMX via the &lt;code&gt;MBeanPluginContext&lt;/code&gt; and can query any MBean in the system.&lt;/p&gt;
&lt;p&gt;But that is only the beginning. There are still a lot of design decisions to take:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How should health check specification look like ? Should it be done via JSON or should a more expressive DSL based e.g. on Groovy should be used ?&lt;/li&gt;
&lt;li&gt;How are the health check store on the agent side ?
&lt;ul&gt;
&lt;li&gt;Looking them up in the filesystem (from a configurable path with a sane default like &lt;code&gt;~/.jolokia_healthchecks&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Baking it into the agent jar&lt;/li&gt;
&lt;li&gt;Uploading it via an MBean operation (and then storing them in the filesystem as well)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;What kind of meta data should be provided so that consoles like hawt.io can dynamically create their health check views ?&lt;/li&gt;
&lt;li&gt;How should the parameter and return value for the health checks look like ?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you would like to participate, the discussion about the implementation details will take place in issue &lt;a href="https://github.com/rhuss/jolokia-extra/issues/1" target="_blank" rel="noreferrer"&gt;#1&lt;/a&gt; and the current working state is summarized in this &lt;a href="https://github.com/rhuss/jolokia-extra/wiki/Health-Checks" target="_blank" rel="noreferrer"&gt;wiki page&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Spicy Docker Java Images with Jolokia</title><link>https://ro14nd.de/jolokia-docker-image/</link><pubDate>Thu, 09 Oct 2014 00:00:00 +0000</pubDate><guid>https://ro14nd.de/jolokia-docker-image/</guid><description>&lt;p&gt;While on the way of transforming the &lt;a href="http://www.jolokia.org" target="_blank" rel="noreferrer"&gt;Jolokia&lt;/a&gt; integration test suite from a tedious, manual, half-a-day procedure to a full automated process I ran into and felt in love with &lt;a href="http://docker.io" target="_blank" rel="noreferrer"&gt;Docker&lt;/a&gt;. As a byproduct a &lt;a href="https://registry.hub.docker.com/u/jolokia/java-jolokia/" target="_blank" rel="noreferrer"&gt;java-jolokia&lt;/a&gt; docker repository emerged, which can be easily used as a Java base image for enabling a Jolokia JVM agent during startup for any Java application.&lt;/p&gt;
&lt;p&gt;These images are variants of the official &lt;a href="https://registry.hub.docker.com/_/java" target="_blank" rel="noreferrer"&gt;java&lt;/a&gt; Java docker image. In order to use the Jolokia agent, a child image should call the script &lt;code&gt;jolokia_opts&lt;/code&gt; (which is in the path). This will echo all relevant startup options that should be included as argument to the Java startup command.&lt;/p&gt;
&lt;p&gt;Here is a simple example for creating a Tomcat 7 images which starts Jolokia along with Tomcat:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;FROM jolokia/java-jolokia:7
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ENV TOMCAT_VERSION 7.0.55
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ENV TC apache-tomcat-${TOMCAT_VERSION}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;EXPOSE 8080 8778
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;RUN wget http://archive.apache.org/dist/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/${TC}.tar.gz
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;RUN tar xzf ${TC}.tar.gz -C /opt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CMD env CATALINA_OPTS=$(jolokia_opts) /opt/${TC}/bin/catalina.sh run&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(&lt;em&gt;Don&amp;rsquo;t forget to use &lt;code&gt;$(jolokia_opts)&lt;/code&gt; or with backticks, but not &lt;code&gt;${jolokia_opts}&lt;/code&gt;&lt;/em&gt;)&lt;/p&gt;
&lt;p&gt;The configuration of the Jolokia agent can be influenced with various environments variables which can be given when starting the container:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;JOLOKIA_OFF&lt;/code&gt; : If set disables activation of Jolokia. By default, Jolokia is enabled.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;JOLOKIA_CONFIG&lt;/code&gt; : If set uses this file (including path) as Jolokia JVM agent properties (as described in Jolokia&amp;rsquo;s &lt;a href="http://www.jolokia.org/reference/html/agents.html#agents-jvm" target="_blank" rel="noreferrer"&gt;reference manual&lt;/a&gt;. By default this is &lt;code&gt;/opt/jolokia/jolokia.properties&lt;/code&gt;. If this file exists, it will automatically be taken as configuration&lt;/li&gt;
&lt;li&gt;&lt;code&gt;JOLOKIA_HOST&lt;/code&gt; : Host address to bind to (Default: 0.0.0.0)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;JOLOKIA_PORT&lt;/code&gt; : Port to use (Default: 8778)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;JOLOKIA_USER&lt;/code&gt; : User for authentication. By default authentication is switched off.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;JOLOKIA_PASSWORD&lt;/code&gt; : Password for authentication. By default authentication is switched off.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, if you start your tomcat with &lt;code&gt;docker run -e JOLOKIA_OFF&lt;/code&gt; no agent will be started.&lt;/p&gt;
&lt;p&gt;Currently this image is available from &lt;a href="https://registry.hub.docker.com/u/jolokia/java-jolokia/" target="_blank" rel="noreferrer"&gt;Docker Hub&lt;/a&gt; for the latest versions of Java 6,7 and 8, respectively, as they are provided by the official Docker &lt;a href="https://registry.hub.docker.com/_/java/" target="_blank" rel="noreferrer"&gt;java&lt;/a&gt; image.&lt;/p&gt;
&lt;p&gt;Other base images can be easily added by using the configuration and templates from a super simple node based &lt;a href="https://github.com/rhuss/docker-java-jolokia" target="_blank" rel="noreferrer"&gt;build system&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;All appserver images from &lt;a href="https://github.com/ConSol/docker-appserver" target="_blank" rel="noreferrer"&gt;ConSol/docker-appserver&lt;/a&gt; (&lt;a href="https://registry.hub.docker.com/repos/consol/" target="_blank" rel="noreferrer"&gt;Docker Hub&lt;/a&gt;) are based now on this image, so Jolokia will always be by your side ;-)&lt;/p&gt;</description></item><item><title>Jolokia and CORS</title><link>https://ro14nd.de/jolokia-cors/</link><pubDate>Mon, 18 Aug 2014 00:00:00 +0000</pubDate><guid>https://ro14nd.de/jolokia-cors/</guid><description>&lt;p&gt;&lt;a href="http://www.jolokia.org" target="_blank" rel="noreferrer"&gt;Jolokia&lt;/a&gt; has configurable &lt;a href="http://www.w3.org/TR/cors/" target="_blank" rel="noreferrer"&gt;CORS&lt;/a&gt; support so that it plays nicely together with the Browser world when it comes to cross origin requests. However, Jolokia’s CORS support is not without gotchas. This post explains how Jolokias CORS supports works, what are the issues and how I plan to solve them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;tldr;&lt;/strong&gt; &lt;em&gt;Jolokia CORS support is configured via &lt;code&gt;jolokia-access.xml&lt;/code&gt; but has issues with authenticated requests which are tackled for the next release 1.3.0&lt;/em&gt;&lt;/p&gt;

&lt;h2 class="relative group"&gt;CORS Primer
 &lt;div id="cors-primer" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#cors-primer" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://www.w3.org/TR/cors/" target="_blank" rel="noreferrer"&gt;CORS&lt;/a&gt; (Cross Origin Resource Sharing) is a specification for browsers to allow controlled access for JavaScript code to locations which are different than the origin of the JavaScript code itself.&lt;/p&gt;
&lt;p&gt;In simple cases, it works more or less like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A JavaScript code (coming from the original location &lt;em&gt;&lt;a href="http://a.com" target="_blank" rel="noreferrer"&gt;http://a.com&lt;/a&gt;&lt;/em&gt;) requests HTTP access via &lt;code&gt;XMLHttpRequest&lt;/code&gt; to &lt;em&gt;&lt;a href="http://b.com" target="_blank" rel="noreferrer"&gt;http://b.com&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Since the the origin of the script and target URL of the request differs, the browser adds some extract checking on the response of this request.&lt;/li&gt;
&lt;li&gt;The request to &lt;em&gt;b.com&lt;/em&gt; contains a header &lt;code&gt;Origin: http://a.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The server at &lt;em&gt;b.com&lt;/em&gt; answering the request has to decided upon this header whether it wants allow this request. The server decision is contained in the response header &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The value of this header can be either a literal URL (e.g. &lt;em&gt;&lt;a href="http://a.com" target="_blank" rel="noreferrer"&gt;http://a.com&lt;/a&gt;&lt;/em&gt;) or a wildcard like in &lt;code&gt;Access-Control-Allow-Origin: *&lt;/code&gt; which allows access from any original location.&lt;/li&gt;
&lt;li&gt;The browser finally decides whether it returns the response to the JavaScript based on the returned access control header. If not, is throws an exception before handing out the response data.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is it for &lt;em&gt;simple requests&lt;/em&gt;. A simple request has the following characteristics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;HTTP method is either &lt;code&gt;GET&lt;/code&gt;,&lt;code&gt;HEAD&lt;/code&gt; or &lt;code&gt;POST&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The request contains only the following headers
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Accept&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Accept-Language&lt;/code&gt; or &lt;code&gt;Content-Language&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Content-Type&lt;/code&gt; with the value &lt;code&gt;application/x-www-form-urlencoded&lt;/code&gt;, &lt;code&gt;multipart/form-data&lt;/code&gt; or &lt;code&gt;text/plain&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If this criteria are not match for a request (e.g. because it uses a different method or additional headers), a so called &lt;a href="http://www.w3.org/TR/cors/#resource-preflight-requests" target="_blank" rel="noreferrer"&gt;preflight request&lt;/a&gt; is sent to the server before the actual request is performed. The preflight is an HTTP request with method &lt;code&gt;OPTIONS&lt;/code&gt; and contains the headers &lt;code&gt;Origin&lt;/code&gt; (&lt;em&gt;&lt;a href="http://a.com" target="_blank" rel="noreferrer"&gt;http://a.com&lt;/a&gt;&lt;/em&gt; in our case), &lt;code&gt;Access-Control-Request-Method&lt;/code&gt; for the HTTP method requested and &lt;code&gt;Access-Control-Request-Headers&lt;/code&gt; with a comma separated list of additional header names. The server in turn answers with the allowed request methods and headers, whether an authenticated request is allowed and how long the client might cache this answer. An important point is, that a preflight request &lt;a href="http://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0" target="_blank" rel="noreferrer"&gt;must not be authenticated&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;And in fact, browsers never sent an authentication header with the preflight request even when already authenticated against the target server. More on this later.&lt;/p&gt;

&lt;h2 class="relative group"&gt;Jolokia CORS Support
 &lt;div id="jolokia-cors-support" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#jolokia-cors-support" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;By default, Jolokia allows any CORS request. For the preflight the agent answers with&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Access-Control-Allow-Origin: http://a.com
Access-Control-Allow-Headers: accept, authorization, content-type
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The allowed headers returned are exactly the same headers as requested. For the real request with an origin header &lt;code&gt;Origin: http://a.com&lt;/code&gt; the answer is&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Access-Control-Allow-Origin: http://a.com
Access-Control-Allow-Credentials: true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For best computability Jolokia always answers with the provided &lt;code&gt;Origin:&lt;/code&gt; which is extracted from the request (except when the origin is &lt;code&gt;null&lt;/code&gt; in which case the wildcard &lt;code&gt;*&lt;/code&gt; is returned.&lt;/p&gt;
&lt;p&gt;This behavior can be tuned by adapting the &lt;code&gt;jolokia-access.xml&lt;/code&gt; policy as described in the &lt;a href="http://www.jolokia.org/reference/html/security.html#security-policy" target="_blank" rel="noreferrer"&gt;reference manual&lt;/a&gt; :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;cors&amp;gt;
 &amp;lt;allow-origin&amp;gt;http://www.jolokia.org&amp;lt;/allow-origin&amp;gt;
 &amp;lt;allow-origin&amp;gt;*://*.jmx4perl.org&amp;lt;/allow-origin&amp;gt;

 &amp;lt;strict-checking/&amp;gt;
&amp;lt;/cors&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If a &lt;code&gt;&amp;lt;cors&amp;gt;&lt;/code&gt; section is present in &lt;code&gt;jolokia-access.xml&lt;/code&gt; then only those hosts declared in this sections are allowed. The Origin URLs to match against can be specified either literally or as pattern containing the wildcard &lt;code&gt;*&lt;/code&gt;. The optional declaration &lt;code&gt;&amp;lt;strict-checking/&amp;gt;&lt;/code&gt; is not really connected to CORS but helps in defending against &lt;a href="http://de.wikipedia.org/wiki/Cross-Site-Request-Forgery" target="_blank" rel="noreferrer"&gt;Cross-Site-Request-Forgery&lt;/a&gt; (CSRF). If this option is given, then the given patterns are used for &lt;strong&gt;every&lt;/strong&gt; request to compare it against the &lt;code&gt;Origin:&lt;/code&gt; or &lt;code&gt;Referer:&lt;/code&gt; header (not only for CORS requests).&lt;/p&gt;

&lt;h2 class="relative group"&gt;CORS and Authentication
 &lt;div id="cors-and-authentication" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#cors-and-authentication" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Since &lt;code&gt;Authorization:&lt;/code&gt; is for CORS not a &lt;em&gt;simple&lt;/em&gt; header, when authentication is used, preflight checking is always applied. However, there is often a &lt;a href="https://code.google.com/p/twitter-api/issues/detail?id=2273" target="_blank" rel="noreferrer"&gt;catch 22&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The preflight check using the &lt;code&gt;OPTIONS&lt;/code&gt; HTTP Method &lt;strong&gt;must not be authenticated&lt;/strong&gt; as explained above, so browser doesn’t send the appropriate authentication headers when doing the preflight.&lt;/li&gt;
&lt;li&gt;The Jolokia agent is typically secured completely no matter which HTTP method is used.&lt;/li&gt;
&lt;li&gt;The preflight check fails, the request fails.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The only clean solution is to setup Jolokia Authentication that way that &lt;code&gt;OPTIONS&lt;/code&gt; request are not secured.&lt;/p&gt;
&lt;p&gt;Let’s have a look at the individual Agents:&lt;/p&gt;

&lt;h3 class="relative group"&gt;JVM Agent
 &lt;div id="jvm-agent" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#jvm-agent" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;Since the JVM agent does all the security stuff on its own, it is not a big deal to introduce this specific behavior. Next one.&lt;/p&gt;

&lt;h3 class="relative group"&gt;WAR Agent
 &lt;div id="war-agent" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#war-agent" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;The WAR agent use authentication and authorization as defined in the &lt;a href="https://jcp.org/aboutJava/communityprocess/final/jsr315/" target="_blank" rel="noreferrer"&gt;Servlet Specification&lt;/a&gt;, i.e. the appropriate &lt;code&gt;&amp;lt;security-constraint&amp;gt;&lt;/code&gt; must be added manually to the web.xml (&lt;a href="http://search.cpan.org/~roland/jmx4perl/scripts/jolokia" target="_blank" rel="noreferrer"&gt;jolokia&lt;/a&gt; is a CLI tool which helps in this repackaging). Unfortunately there is no way to secure the same &lt;code&gt;&amp;lt;url-pattern&amp;gt;&lt;/code&gt; differently for different HTTP Methods (i.e. secured with an &lt;code&gt;&amp;lt;auth-constraint&amp;gt;&lt;/code&gt; for &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;POST&lt;/code&gt;, but accessible for everybody for &lt;code&gt;OPTIONS&lt;/code&gt;). I tried hard by providing multiple &lt;code&gt;&amp;lt;security-constraint&amp;gt;&lt;/code&gt; but failed miserably (if you know how to this, please let me know).&lt;/p&gt;
&lt;p&gt;The only solution is to switch over to checking a given role on our own without relying on the declarative JEE security mechanism. Since we can check the role programmatically (&lt;code&gt;HttpServletRequest.isUserInRole()&lt;/code&gt;) this should not be that big deal. But it’s still some work ….&lt;/p&gt;

&lt;h3 class="relative group"&gt;OSGi Agent
 &lt;div id="osgi-agent" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#osgi-agent" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;When using an &lt;a href="http://www.osgi.org/javadoc/r4v42/org/osgi/service/http/HttpService.html" target="_blank" rel="noreferrer"&gt;OSGI HttpService&lt;/a&gt; adding this behavior should not be difficult since security is handled programmatically here as well (&lt;code&gt;HttpContext.handleSecurity()&lt;/code&gt;)&lt;/p&gt;

&lt;h3 class="relative group"&gt;Other Agent variants
 &lt;div id="other-agent-variants" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#other-agent-variants" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;This is the dark matter, because I don’t know where and how Jolokia is integrated directly into a bigger context. I know that &lt;a href="http://activemq.apache.org/rest.html" target="_blank" rel="noreferrer"&gt;ActiveMQ&lt;/a&gt;, &lt;a href="http://karaf.apache.org/manual/latest/users-guide/monitoring.html" target="_blank" rel="noreferrer"&gt;Karaf&lt;/a&gt; and &lt;a href="https://github.com/spring-projects/spring-boot/blob/master/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc" target="_blank" rel="noreferrer"&gt;Spring Boot&lt;/a&gt; uses Jolokia internally. In order to support authenticated CORS access they probably needs to be changed to allow unauthorized &lt;code&gt;OPTIONS&lt;/code&gt; access for everybody. Since this is not under my control I have no idea when and even whether it ever will happen. Generic purpose console like &lt;a href="http://hawt.io" target="_blank" rel="noreferrer"&gt;hawt.io&lt;/a&gt; rely in some setups on CORS access so it would be real cool if we can get it out there. Help with this is highly appreciated ;-)&lt;/p&gt;

&lt;h2 class="relative group"&gt;Roadmap
 &lt;div id="roadmap" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#roadmap" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Since 1.2.2 is already finished and about to be published today, the stuff I can do as described above will go into a 1.3.0. Looking back at my release history this will probably be ready approx. end of august.&lt;/p&gt;</description></item></channel></rss>