I'm seeing odd behavior with the JMX API implementation in Wildfly 11.
If you grab this Makefile and two .java files I use for testing you can see it yourself -
just put these in a tmp directory somewhere:
wget
https://raw.githubusercontent.com/jmazzitelli/test/master/javaagent/Makefile
wget
https://raw.githubusercontent.com/jmazzitelli/test/master/javaagent/TestJ...
wget
https://raw.githubusercontent.com/jmazzitelli/test/master/javaagent/TestJ...
Then just run "make download-wildfly unzip-wildfly compile run" (make sure you
don't have other WildFly servers running to avoid port conflicts)
This runs WF 11 with a -javaagent attached. In the server output, you will see this:
16:31:05,290 INFO [stdout] (Test Java Agent Thread)
=============================================================
16:31:05,291 INFO [stdout] (Test Java Agent Thread) FIND INFORMATION ABOUT MBEAN:
jboss.as:management-root=server
16:31:05,291 INFO [stdout] (Test Java Agent Thread)
=============================================================
16:31:05,291 INFO [stdout] (Test Java Agent Thread) isRegistered:
16:31:05,291 INFO [stdout] (Test Java Agent Thread) true
16:31:05,291 INFO [stdout] (Test Java Agent Thread) getMBeanInfo:
16:31:05,291 INFO [stdout] (Test Java Agent Thread) description: The root node of the
server-level management model.
16:31:05,291 INFO [stdout] (Test Java Agent Thread) #attributes: 19
16:31:05,291 INFO [stdout] (Test Java Agent Thread) getAttribute:
16:31:05,291 INFO [stdout] (Test Java Agent Thread) serverState=reload-required
16:31:05,291 INFO [stdout] (Test Java Agent Thread) queryNames:
16:31:05,291 INFO [stdout] (Test Java Agent Thread) []
16:31:05,291 INFO [stdout] (Test Java Agent Thread) queryMBeans:
16:31:05,291 INFO [stdout] (Test Java Agent Thread) []
16:31:05,291 INFO [stdout] (Test Java Agent Thread) queryNames(null, null):
16:31:05,291 INFO [stdout] (Test Java Agent Thread) FOUND IT:
jboss.as:management-root=server
16:31:05,291 INFO [stdout] (Test Java Agent Thread)
=============================================================
You will see SOME JMX APIs can see the MBean "jboss.as:management-root=server",
but queryMBeans and queryNames canNOT (note the empty arrays []).
But notice getMBeanInfo CAN see it - I can even get the serverState attribute value from
that (you can see it is in reload-required state - I see the same behavior even if it was
in "running" state).
But again, queryMBeans returns nothing.
Oddly, queryNames(null, null) DOES return it in the list (see the "FOUND IT"
line). It is only if I specifically ask for it does it fail in the query API.
Finally, note that it seems this MBean "jboss.as:management-root=server" is
special - because it is specifically broke - if i switch to querying for
"jboss.as:subsystem=transactions" it all works fine, even the query APIs:
17:16:39,541 INFO [stdout] (Test Java Agent Thread) queryNames:
17:16:39,541 INFO [stdout] (Test Java Agent Thread) [jboss.as:subsystem=transactions]
17:16:39,541 INFO [stdout] (Test Java Agent Thread) queryMBeans:
17:16:39,541 INFO [stdout] (Test Java Agent Thread)
[org.jboss.as.controller.ModelController[jboss.as:subsystem=transactions]]
This problem was seen by others as well (with the same MBean I'm trying to get) -
see:
https://github.com/prometheus/jmx_exporter/issues/89
The person there claims queryNames is broke but queryMBeans is OK - that does not work in
my example either. Neither query API works.
I searched JIRA, found nothing related to this MBean not being queryable.