Get the name of the server in which I am receiving requests to my app on weblogic?

青春壹個敷衍的年華 提交于 2019-12-08 12:37:05

问题


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;

回答1:


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");


来源:https://stackoverflow.com/questions/8792703/get-the-name-of-the-server-in-which-i-am-receiving-requests-to-my-app-on-weblogi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!