How to get the list of MBeans in WildFly

This article shows how to fetch the list of MBeans which are available in WildFly application server and check their properties

Getting started with the JMXConnector

As per JMX Specification, client applications can obtain MBeans through an MBean server connection, accessed by means of a JMX connector. In this article we will show how to open the MBean server connection towards a WildFly application server.

Firstly, you need to create a Management User to access the remote JBoss / WildFly Server. (f.e. “admin”,”admin” in our example).

./ -m -u admin -p admin

Next, let’s code the following example Class:

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class JMXListMBeans {

    public static void main(String[] args) {



    private static void printMBeans() {

        try {
            String host = "localhost";
            int port = 9990;  // management-http port
            String urlString = "service:jmx:remote+http://" + host + ":" + port;
            JMXServiceURL serviceURL = new JMXServiceURL(urlString);

            Map map = new HashMap();
            String[] credentials = new String[] { "admin", "admin" };
            map.put(JMXConnector.CREDENTIALS, credentials);

            JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, map);

            MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();           
            Set mySet = connection.queryNames(new ObjectName("*:*"), null);
            Iterator it = mySet.iterator();

            while (it.hasNext()) {

                ObjectName myName = (ObjectName); 

                try {
                    System.out.println("--> " + myName.getCanonicalName());

                    // get all attributes

                    MBeanAttributeInfo[] atribs = connection.getMBeanInfo(myName).getAttributes();

                    for (int i = 0; i < atribs.length; i++)  {

                        System.out.println("         Attribute: " + atribs[i].getName() +
                                "   of Type : " + atribs[i].getType());


                    // get all operations

                    MBeanOperationInfo[] operations =

                    for (int i = 0; i < operations.length; i++)  {
                        System.out.print("         Operation: " +
                                operations[i].getReturnType() + "  " +
                                operations[i].getName() + "(");

                        for (int j = 0; j < operations[i].getSignature().length;j++)
                                    getName() + ":" +
                                    getType() + "  ");



                } catch (Exception ex) {






        catch (Exception ex) {





By running the above Class, you will see in the console the list of Attributes and Operations available for every MBean running on WildFly:

wildfly mbeans list jboss

On the other hand, if you want the read the value of an Attribute, cast the Object with the Attribute in a For example:

Object o = jmxConnector.getMBeanServerConnection().getAttribute(new ObjectName("java.lang:type=Memory"), "HeapMemoryUsage");
CompositeData cd = (CompositeData) o;

In the above example, we are fetching the value of the Attribute committed for the ObjectName “java.lang:type=Memory” “HeapMemoryUsage”.

Finally, please note that you need to include in your application’s classpath the jboss-client JAR files in order to be able to use the remote+http protocol:


Other programmatic approaches

The above example shows how to use the JMX API to call an MBean via MBeanServer can be tedious: it involves a reflection-like syntax and a complex exception handling. If you want to use a simpler paradigm you can switch to the Jolokia Client API.

Check this article for more details: Monitor JBoss AS with Jolokia

Found the article helpful? if so please follow us on Socials