本文介绍了获取我在 weblogic 上接收对我的应用程序的请求的服务器的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道我的应用从哪个服务器响应任何网络请求.我正在尝试与 ServerMBeans 建立本地连接,但我只能在任何端口获取 AdminServer.这是代码:
I need to know from which server is my app responding at any web request. I'm trying to make local connection with ServerMBeans, but I only get the AdminServer at any port. here is the code:
String serverName = "";
MBeanHome mbean = null;
try {
InitialContext ctx = new InitialContext();
mbean = (MBeanHome) ctx.lookup("java:comp/env/jmx/runtime");
serverName = mbean.getMBeanServer().getServerName();
} catch (Exception ex) {
serverName = ex.getMessage();
}
return serverName;
推荐答案
刚刚在 WebLogic 11g 中测试了以下摘录,效果非常好.这对你来说是一个选择吗?我想它也适用于以前的版本.
Just tested the following excerpt in WebLogic 11g and worked like a charm. Could that be an option for you? I guess it also works in previous versions.
String serverName = System.getProperty("weblogic.Name");
这篇关于获取我在 weblogic 上接收对我的应用程序的请求的服务器的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!