Monday, July 25, 2016

Weblogic 12.2.1:Java - JMX to get the Server Name and port

 The following section of code discusses how to get the Server Name and Port for the managed server or a cluster where the API is deployed.

     public static Integer getPort() {
       Integer port=null; 
       try {
            InitialContext ctx = new InitialContext();
            String serverName = System.getProperty("weblogic.Name");

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

            ObjectName objName =
                new ObjectName("com.bea:Name=" + serverName + ",Type=Server");
            port = (Integer)server.getAttribute(objName, "ListenPort");
            
            ctx.close();
             
            
        } catch (Exception e) {
            e.printStackTrace();
        }
        return port;
    }

1 comment:

SOA Cloud 12c GIT Repository

When a project is created, you can choose to initialize the project with one project Git repository for the project. A Maven repository is a...