By Calle Wilund
OSv is a great way to run Java applications in the cloud, and it recently became just a little bit better. As you are probably aware, OSv exposes quite a bit of information and manageability options through its RESTful API, accessible through the built-in HTTP server. More or less from its inception, this API has exposed various aspects of the JVM and the Java Management Beans provided.
Recently we improved on this a bit by including the Jolokia JMX-via-JSON-REST connector, providing full read/write access to the entire set of Java manageability attributes and operations. Now you no longer need to set up and secure separate JMX-over-RMI connectivity with your Java application to fully manage it.
The Jolokia API is available via the OSv REST server at
With the result of something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Important note about REST requests and browser security
Most browsers today enforce that resources such as REST queries may only be made to the same domain as the requesting web page. When you want to allow cross-domain requests you need to either turn off this security feature in your browser (for Google Chrome you can run it with
--disable-web-security, however if you use Firefox I do not know of any way to do it), or enable CORS in OSv.
To do the latter, you need to provide a
httpserver configuration section in your cloud init settings. To simply allow all domains to make requests to the OSv APIs, add this to your configuration:
And make this reachable through your cloud-init server. (Or use the EC2 simulator script provided with OSv).
A small demo
To test the demo, simply clone the repository and edit the
src/js/osvhost.js to match the IP address and port for your OSv instance. (Don’t forget to make sure that your OSv image includes the HTTP server).
Since I am runnning OSv compiled from source, I simply go to my OSv source tree and type:
…<chug, chug, chug> And when it is done:
This will build and start an almost empty image, containing only the HTTP server, cloud init support and the Java-based shell (not a very interesting appliance, I admit, but you can pick any image you prefer). Running like this, the REST API is available from
http://localhost:8000, so this is what I enter into
Then load the
jolokia-demo/src/index.html in your favourite browser, and you should be greeted by this:
Having Jolokia integrated in the OSv manageability layer means that not only can you access all the JMX attributes parallel with the rest of the exposed OSv aspects, not having to modify Java appliances, but also that you only need to deal with securing a single service point.
This is just one small aspect of all the new and exciting manageability features that are in or coming to OSv. Over the next few months we hope to bring you additional aspects that will further enhance your deployment experience. Stay tuned.