6 Replies Latest reply on Sep 23, 2014 6:23 AM by sarfaraz-alam.md

    Programmatic MBean access under JBoss AS 7.1 via jmx to find servername, hostname and port in JBoss AS 7

    sarfaraz-alam.md

      Hello All,

      I have been struggling from 2 days with the programmatic access of MBeans under JBoss AS 7.1 via jmx to find servername, hostname and port. Actually i am migrating my application from weblogic 10.3.6 to jboss AS 7.1. While in case of weblogic i was doing like this to get the desire servername, hostname and port via jmx programmatically :



      ObjectName service = new ObjectName(

               "com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");

        InitialContext initialContext = new InitialContext();

        MBeanServer server = (MBeanServer) initialContext.lookup("java:comp/env/jmx/runtime");

        ObjectName runtime = (ObjectName) server.getAttribute(service, "ServerRuntime");

        String rawHostName = (String) server.getAttribute(runtime, "ListenAddress");

        String serverName = (String) server.getAttribute(runtime, "Name");

        Integer serverPort = (Integer) server.getAttribute(runtime, "ListenPort");

        String hostName = rawHostName.substring(0, rawHostName.indexOf('/'));

        LoadConfiguration.LOGGER.debug("setUpServerVariables serverName: {}", serverName);

        LoadConfiguration.LOGGER.debug("setUpServerVariables serverPort: {}", serverPort);

        LoadConfiguration.LOGGER.debug("setUpServerVariables rawHostName: {}", rawHostName);

        LoadConfiguration.LOGGER.debug("setUpServerVariables hostName: {}", hostName);

        System.setProperty("WEBLOGIC_HOST_NAME", hostName);

        System.setProperty("WEBLOGIC_SERVER", serverName);

        System.setProperty("WEBLOGIC_PORT", serverPort.toString());

       

       

      But in case of Jboss AS 7.1 i don't know the exact object name which will give me servername, hostname and port no.  even i went to jconsole and try to search but futile .

      Can any body help me here?? please