[英]Need to get the weblogic hostname where my application is deployed from within my java code
I have the following piece of code from where i can get the Admin server name and the port. 我有以下代码,可以从其中获取管理服务器名称和端口。
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");
Integer port = (Integer)server.getAttribute(objName, "ListenPort");
System.out.println("Server Name :" + serverName + " PORT :" + port);
But I also need the weblogic hostname along with the server name. 但是我还需要weblogic主机名和服务器名。 Not sure how to get that.
不确定如何获得。
It sounds like in addition, you want the "listen address": 听起来,您还想要“收听地址”:
Via Java/JMX: 通过Java / JMX:
String listenAddress=(String)server.getAttribute(objName,"ListenAddress");
Via WLST script: 通过WLST脚本:
cd('Servers/' + serverName)
listenAddress=str(get('ListenAddress'))
print "Listen Address is: " , listenAddress
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.