-
1. Re: [Wildfly 10] Retrieve management port on Domain mode
emeuwese Jul 23, 2018 12:48 PM (in response to bangngo1508)java.lang.management.ManagementFactory.getPlatformMBeanServer().getAttribute(new javax.management.ObjectName("jboss.as:socket-binding-group=full-ha-sockets,socket-binding=http"), "port");
For the socket-bindding http the code returns the same port as in my domain.xml
I think your problem is that in standalone.xml there is a socket-binding-group with a socket-bindding for management-http and in domain.xml there is no socket-binding for management-http. The socket for management-interfaces in host.xml has the attribute port.
-
2. Re: [Wildfly 10] Retrieve management port on Domain mode
bangngo1508 Jul 23, 2018 11:13 PM (in response to emeuwese)Hi Erik
I got the point and tried to configure management port on domain.xml but configuring the management port in domain.xml seem like not the purpose of domain.xml it should be place in host.xml. I tried with below ObjectName instead but it did not work
jboss.as:host=master,core-service=management,management-interface=http-interface
I tried to do following class with key above on server and it worked but then it needs management port to connect so it does not make any sense to go down that way.
import java.util.*; import java.util.Hashtable; import java.io.IOException; import javax.management.MBeanServerConnection; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import java.lang.management.MemoryMXBean; import java.lang.management.ManagementFactory; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import javax.management.*; import javax.management.openmbean.CompositeDataSupport; public class JMXExample { public static void main(String[] args) throws Exception { //Get a connection to the WildFly MBean server on localhost String host = "localhost"; int port = 9990; // management-web port String urlString = System.getProperty("jmx.service.url","service:jmx:remote+http://" + host + ":" + port); JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); System.out.println("getting " + args[0] + "..."); MBeanInfo beanInfo = connection.getMBeanInfo(new ObjectName(args[0])); if(beanInfo != null && beanInfo.getAttributes() != null){ for(int i = 0; i < beanInfo.getAttributes().length; i++){ System.out.println(connection.getAttribute(new ObjectName(args[0]), beanInfo.getAttributes()[i].getName())); System.out.println(beanInfo.getAttributes()[i].getName()); } } else { System.out.println("null"); } jmxConnector.close(); } }