How to connect SpringBoot JMX beans with Jolokia?

2019-07-30 12:20发布

I'm using @EnableMBeanExport in a SpringBoot application to make my beans with @ManagedResource be available to the JMX server. This works fine in simple local processes with VisualVM.

I'm now trying to add Jolokia into the mix, so I can reference those beans remotely with a REST service instead of setting up a remote RMI connection, which is annoying.

The Jolokia doc page at https://jolokia.org/reference/html/jmx.html says to use the following:

MBeanServer jolokiaServer = JolokiaMBeanServerUtil.getJolokiaMBeanServer();

However, there doesn't appear to be a "JolokiaMBeanServerUtil" class in Jolokia.

Update:

Ok, I found the artifact with the class, but the solution doesn't appear to be as simple as just declaring a bean with this value. When I attempt to call a jmx method with a jolokia url, I get an exception like the following:

java.lang.IllegalArgumentException: Invalid object name. Key properties cannot be empty
    at org.jolokia.request.JmxRequestFactory.createGetRequest(JmxRequestFactory.java:99)
    at org.jolokia.http.HttpRequestHandler.handleGetRequest(HttpRequestHandler.java:79)
    at org.jolokia.http.AgentServlet$4.handleRequest(AgentServlet.java:470)

0条回答
登录 后发表回答