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;
}