weblogic.jar 中哪里获取 Weblogic 服务器端口信息

发布于 2024-11-07 18:32:45 字数 328 浏览 0 评论 0原文

我正在尝试使用几类 weblogic 来监控应用程序性能。

我在尝试查找 weblogic 的服务器端口(侦听 http/https 请求)信息时遇到了一些问题。

查看weblogic javadocs,可以使用ServerMBean的setListenPort(int port)来识别端口。但是,这会针对所有已配置的服务器调用。但是,当 Config.xml 中没有为该元素配置监听端口时,不会调用 setListenPort。

当然,当未配置listen-port时,MBean impl内部的值默认为7001。

有没有更好的方法来查找weblogic的web服务器端口?

I'm trying to instrument few classes of weblogic to monitor the application performance.

I'm facing few issues while trying to find the weblogic's server port(that listens to http/https requests) information.

Looking into weblogic javadocs, ServerMBean's setListenPort(int port) can be used to identify the port. However, this is called for all the configured servers. But setListenPort is not called when listen-port is not configured for the element in Config.xml.

Of course, the value inside the MBean impl defaults to 7001 when listen-port is not configured.

Is there a better way to find the web server port of weblogic?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空心空情空意 2024-11-14 18:32:45

以下代码向 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 + "/";

The following code queries the MBeanServer for the URL of the runtime environment it is running in:

    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 + "/";
朱染 2024-11-14 18:32:45

我经常查看的地方是管理服务器启动的输出 - 日志文件通常足够好,可以在“服务器状态现在正在运行”消息之前留下一条记录,该消息列出了管理控制台所在的 IP 和端口号正在听...

The place I've always looked is the output of the Admin Server startup - the log file is often nice enough to leave a record right before the "Server status is now RUNNING" message that lists the IP and port number that the admin console is listening on...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文