我正在尝试使用几个weblogic类来监控应用程序的性能。
在尝试查找weblogic的服务器端口(侦听http/https请求)信息时,我遇到了一些问题。
查看weblogic javadoc,ServerMBean的setListenPort(int端口)可以用来标识端口。但是,这是为所有已配置的服务器调用的。但是,如果没有为Config.xml中的元素配置侦听端口,则不会调用setListenPort。
当然,当未配置侦听端口时,MBean impl内的值默认为7001。
有没有更好的方法来找到weblogic的web服务器端口?
发布于 2012-04-29 16:57:22
下面的代码在MBeanServer中查询它所运行的运行时环境的URL:
JVMID jvmid = JVMID.localID();
String serverName = jvmid.getServerName();
String serverAddress = jvmid.getAddress();
InitialContext ctx = new InitialContext();
MBeanServer server = (MBeanServer) ctx.lookup("java:comp/env/jmx/runtime");
// weblogic.management.configuration.ServerMBean
ObjectName objName = new ObjectName("com.bea:Name=" + serverName + ",Type=Server");
// weblogic.management.configuration.SSLMBean
ObjectName sslObjName = new ObjectName("com.bea:Name=" + serverName + ",Type=SSL,Server=AdminServer");
int port = (Integer) server.getAttribute(objName, "ListenPort");
boolean https = (Boolean) server.getAttribute(sslObjName, "Enabled");
return "http" + (https ? "s" : "") + "://" + serverAddress + ":" + port + "/";发布于 2011-05-21 04:25:14
我一直在寻找的地方是管理服务器启动的输出-日志文件通常足够好,可以在"Server status is now RUNNING“消息之前留下一条记录,该消息列出了管理控制台正在侦听的IP和端口号……
https://stackoverflow.com/questions/6041054
复制相似问题