Saturday, January 24, 2015

Openfire3.9.1 JMX | Openfire 3.9.1 - Enable Secure/Non-Secure JMX

Openfire System Properties for JMX

First, you need to add the following to System Properties via the Web Admin Console or add into the table ofproperty.
xmpp.jmx.enabled true
xmpp.jmx.port 9111
xmpp.jmx.secure false

Code Snippet

To test it, use the code snippet:
String serverUrl = "service:jmx:rmi:///jndi/rmi://localhost:9111/jmxrmi";

JMXServiceURL url = new JMXServiceURL(serverUrl);

JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

ObjectName objectName = new ObjectName("org.eclipse.jetty.webapp:type=webappcontext,id=0,name=ROOT");

Object response = mbsc.getAttribute(objectName, "started");

jmxc.close();
Open your own Online Store and Grow Your Sales! Try it Free Now with Bigcommerce!

Configure Username and Password for Secure JMX

You could tighten the security by change xmpp.jmx.secure to true. In this case, user name and password must be supplied during connection establishment.
String serverUrl = "service:jmx:rmi:///jndi/rmi://localhost:9111/jmxrmi";

JMXServiceURL url = new JMXServiceURL(serverUrl);

Map<String, String[]> map = Collections.singletonMap(JMXConnector.CREDENTIALS, new String[]{"admin", "password"});

JMXConnector jmxc = JMXConnectorFactory.connect(url, map);

MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

ObjectName webAppContext = new ObjectName("org.eclipse.jetty.webapp:type=webappcontext,id=0,name=ROOT");

Object response = mbsc.getAttribute(webAppContext, "started");

jmxc.close();

Configure JBoss for Enabling JMX RMI

If you deploy your application to JBoss AS 7.1.1, you also need to update $JBOSS_HOME/modules/sun/jdk/main/module.xml by adding the following:
to the "paths" section.


Create a Successful Online Store at Bigcommerce! Try it Free Now!

No comments:

Post a Comment