-
1. Re: How to retrieve programmatically the management host and port
mayerw01 Aug 15, 2015 9:58 AM (in response to kalzzz)This should provide you the management host address via JMX:
MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
ObjectName objectName = new ObjectName("jboss.as:interface=management");
String attrib = "";
try {
attrib = (String) server.getAttribute(objectName, "inetAddress");
...
I understand that the native management port uses the abyss service in domain mode.
So in linux the command 'nmap -v localhost | grep abyss' should show an output like
9999/tcp open abyss
-
2. Re: How to retrieve programmatically the management host and port
kalzzz Aug 17, 2015 9:01 AM (in response to mayerw01)Thank you for the quick anwser, Wolfgang Mayer.
Indeed with the jboss.as:interface=management object i can get the host controller IP
But the object don't contain other util stuff.
Actually, i also need the port because it can be something else than 9999 (for exemple , because of a JBoss offset port setting)
It seems that the port information is missing in the jmx tree in domain mode.
More than that when my running application is not on the domain controller computer, i d'like to connect to the remote domain controller (for the full cluster view)
And in this case again, no possible help by the JMX view...
I'm currently thinking about a solution using the JBoss host.xml file.
For example, reading the <domain-controller><remote> tag.
I have the location of the file with the JMX key jboss.as:path=jboss.domain.config.dir
But The difficulty is that the name can be something different of host.xml (if launch command --host-config=my-custom-host.xml is used )So i'm still looking for a more reliable solution
(the linux command nmap is not possible because the jboss can run on a windows plateform).
-
3. Re: How to retrieve programmatically the management host and port
mayerw01 Aug 17, 2015 12:15 PM (in response to kalzzz)I doubt that you will be able to get the "real" port from the configuration. This issue apparently exists also in standalone mode Obtain http port programatically fails on Wildfly 8.1.0
I still think that the only reliable information will come from the operating system using some port scanner as described above
-
4. Re: How to retrieve programmatically the management host and port
kalzzz Aug 24, 2015 8:51 AM (in response to kalzzz)Finally, I implemented this solution :
1) connection to the host controller with jboss-cli to retrieve the "domain-controler" informations (better than reading the host.xml because its name can be changed)
2) connection to the domain controller with jboss-cli to retrieve the whole cluster informations (all hosts and server...)However things are still fishy in the point 1)
-no clean solution to retrieve the management host and port , so i pick properties jboss.bind.address.management and jboss.management.native.port when available or default 127.0.0.1:9999 (but offset settings are still a problem)
-the readed domain-controler object can contains JBoss expression like ${jboss.domain.master.address}" and in this case, no idea how to resolve them