Hi,

Jay SenSharma

Jay SenSharma

We cannot remember all the JMX URLs. Many URL formats are very complex as well to remember. So here is a Program which tells us all the JMX URLs of all the Resources and Runtime MBeans available on WebLogic Server. Just try this tiny code…

This Simple program Displays all the MBeans Names/Url which are registered to a perticular WebLogic Server. Many times it is ery helpful to see if a perticular MBean is actually registered on the Server or not.

Example: If a JDBC resource like DataSource is in the Shutdown state then in that case this program will not display it’s MBean details, because the Shutdown resources MBeans  gets destroyed (Unregistered).


import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXServiceURL;
import javax.management.remote.JMXConnectorFactory;
import java.util.Hashtable;
import java.util.Set;

public class ALL_JMX_URLS {

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

JMXConnector jmxCon = null;
try {
JMXServiceURL serviceUrl = new JMXServiceURL(“service:jmx:iiop://127.0.0.1:7001/jndi/weblogic.management.mbeanservers.runtime”);
System.out.println( “Connecting to:  “+ serviceUrl);
Hashtable env = new Hashtable();
env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, “weblogic.management.remote”);
env.put(javax.naming.Context.SECURITY_PRINCIPAL, “weblogic”);
env.put(javax.naming.Context.SECURITY_CREDENTIALS, “weblogic”);

jmxCon = JMXConnectorFactory.newJMXConnector(serviceUrl, env);
jmxCon.connect();
MBeanServerConnection con = jmxCon.getMBeanServerConnection();

Set<ObjectName> mbeans = con.queryNames(null, null);
for (ObjectName mbeanName : mbeans) {
System.out.println(mbeanName);
}
}
finally {
if (jmxCon != null)
jmxCon.close();
}
}
}

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.