2 Replies Latest reply on Nov 7, 2014 4:01 AM by Jozef Soetaert

    Obtain http port programatically fails on Wildfly 8.1.0

    Jozef Soetaert Newbie

      Hello, we are trying to obtain the http port used by Wildfly with the following code which worked under JBoss AS 7.1 final

                  MBeanServerConnection server = MBeanServerLocator.locateJBoss();

                  ObjectName http =   new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");

                  httpPort = (Integer) server.getAttribute(http, "boundPort");

      The code fails at the server.getAttribute call with an InstanceNotFoundException

      Has the behavior changed in Wildfly or should we use another way to get this port number?

        • 1. Re: Obtain http port programatically fails on Wildfly 8.1.0
          ksreen Newbie

          The attribute should be "port" and not "boundPort".  A simple way to look up the correct atrribute name is connect to the wildfly management through cli and execute the following command "/socket-binding-group=standard-sockets/socket-binding=http:read-resource" .

          • 2. Re: Obtain http port programatically fails on Wildfly 8.1.0
            Jozef Soetaert Newbie

            Hello,

             

            thank you for the reply, but this does not solve my problem.

            This is the output of the cli command to get the information:

            [standalone@localhost:10140 /] /socket-binding-group=standard-sockets/socket-binding=http:read-resource

            {

                "outcome" => "success",

                "result" => {

                    "client-mappings" => undefined,

                    "fixed-port" => false,

                    "interface" => undefined,

                    "multicast-address" => undefined,

                    "multicast-port" => undefined,

                    "name" => "http",

                    "port" => expression "${jboss.http.port:8080}"

                }

            }

            while this wildfly is running with a port offset of 150 (as you can see i am accessing it through port 10140).  I expect to get back 8230 instead of 8080. My Wildfly is using standalone-ha.xml.

            When i use port in the code, i get the same InstanceNotFoundException, which makes me think that i am getting back the wrong MBeanServerConnection from the locateJBoss() call.

            I am running 2 Wildfly instances, one on port 8080, the other one, where i want to get this http port number on 8230. I get the same results, if i stop the instance running on 8080.