Advertise with us

Our eBooks

How to get the list of MBeans in JBoss or WildFy

In order to retrieve the list of MBeans in a remote JBoss EAP or WildFly Server you can use the JMX API as follows.

The pre-requisite is that you create a Management User to access the remote JBoss / WildFly Server. (f.e. "admin","admin" in our example).

Then, here is a sample Main class:

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

public class HelloWorld {
	public static void main(String[] args) throws Exception {

	public static void status() throws Exception{
		String host = "localhost";
		int port = 9990;  // management-http port
		String urlString = "service:jmx:remote+http://" + host + ":" + port;
		System.out.println("\n\n\t****  urlString: "+urlString);;
		JMXServiceURL serviceURL = new JMXServiceURL(urlString);

		Map map = new HashMap();
		String[] credentials = new String[] { "admin", "admin" };
		map.put("jmx.remote.credentials", credentials);
		JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, map);

		MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();

		ObjectName objectName = ObjectName.getInstance("");
		String attributeName = "serverState";
		Object result = connection.getAttribute(objectName, attributeName);




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:

© 2021 All Rights Reserved.

Please publish modules in offcanvas position.