0 Replies Latest reply on May 9, 2017 11:10 AM by papegaaij

    Read socket binding from code at startup

    papegaaij

      Hi,

       

      I'm trying to access a socket-binding from my server configuration in a @Singleton @Startup bean. From what I've found on this forum, is that you can lookup socket bindings using JMX:

      ManagementFactory.getPlatformMBeanServer().getAttribute(
           new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=ldap"), "port");
      

       

      However, during startup, this attribute is not yet available. ManagementFactory.getPlatformMBeanServer().queryNames(null, null) does list the MBean, but reading the 'port' attribute gives an AttributeNotFoundException and the following log:

      17:02:50,324 ERROR [org.jboss.as.controller.management-operation] (EJB default - 2) WFLYCTL0013: Operation ("read-attribute") failed - address: ([
          ("socket-binding-group" => "standard-sockets"),
          ("socket-binding" => "ldap")
      ]) - failure description: "WFLYCTL0216: Management resource '[(\"socket-binding-group\" => \"standard-sockets\")]' not found"
      

      Note that the attribute is available directly after startup (after the log message 'WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in ...'). This includes adding the deployments after starting the container.

       

      How do I access the socket-binding from within a @Singleton bean at @Startup? If not possible, how do I delay the startup of the bean until the server is fully started?

       

      Best regards,

      Emond Papegaaij