DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

JMX Over the Web With Jolokia and Hawtio

Jolokia and Hawtio gives Java developers a powerful way to monitor and manage their Java applications over the web.

Matthew Casperson user avatar by
Matthew Casperson
·
Oct. 21, 16 · Tutorial
Like (6)
Save
Tweet
Share
24.81K Views

Join the DZone community and get the full member experience.

Join For Free

JMX provides Java developers with a powerful set of tools for monitoring and managing their applications. Any developer who has had to dig into the memory usage of their web server or diagnose database connections will have dusted off their copy of jconsole and Googled the default JMX port to try and see what is going on.

But having to connect to JMX over a custom port and protocol can be cumbersome in the real world. I suspect many of those developers who have tried to debug their production servers with JMX quickly found out that corporate firewalls prevented accesses, and the ops guys had blank stares when asked to open up JMX ports. Today everything is done via HTTP and RESTful interfaces, so wouldn’t it be great if you could access JMX via HTTP?

This is where Jolokia comes in. Jolokia is a JMX-HTTP bridge, exposing the power of JMX via a standard RESTful interface that is much easier to consume.

To demonstrate how Jolokia makes JMX easy, I will show you how to quickly combine two JBoss projects: WildFly Swarm and Hawtio.

WildFly Swarm is a standalone version of the popular WildFly Java EE server that provides a number of useful additions above the Java EE spec. Jolokia is one such extension. To build a WildFly Swarm package that includes Jolokia, all you need to do is visit the Swarm Generator, select Jolokia from the list of dependencies, download and extract the generated ZIP file, and build and run it with the Maven command mvn wildfly-swarm:run.

Screen Shot 2016-10-20 at 5.39.10 pm.png

You can confirm that Jolokia is running but opening http://localhost:8080/jolokia in a browser.

Screen Shot 2016-10-20 at 5.40.53 pm.png

The JSON response means that WildFly Swarm is up and running, and that the Jolokia dependency is exposing JMX over HTTP. Which is great, but this JSON is pretty hard to read in its raw form. This is where Hawtio comes in.

To get a copy of Hawtio running, download the standalone JAR file from the Hawtio website and run it with the command java -jar hawtio-app-1.4.66.jar --port 8090. Once Hawtio is started, you can access the dashboard via http://localhost:8090/hawtio.

At this point, you can connect Hawtio to the instance of Jolokia hosted by WildFly Swarm.

Screen Shot 2016-10-20 at 5.30.48 pm.png

And just like that, you have a fully interactive web-based dashboard that allows you to interact with all the JMX interfaces exposed by your web server.

Screen Shot 2016-10-20 at 5.45.32 pm.png

Of course, JMX is about more than just reporting the state of your application; you can also configure your system at runtime, with most enterprise libraries exposing an incredible amount of functionality via JMX operations.

Screen Shot 2016-10-20 at 5.47.35 pm.png

Jolokia and Hawtio are excellent additions to any Java developer's toolbox, providing a wealth of information and functionality via easy to access web dashboards.

swarm

Published at DZone with permission of Matthew Casperson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • When AI Strengthens Good Old Chatbots: A Brief History of Conversational AI
  • The Enterprise, the Database, the Problem, and the Solution
  • AWS Fargate: Deploying Jakarta EE Applications on Serverless Infrastructures
  • Promises, Thenables, and Lazy-Evaluation: What, Why, How

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: