File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Products
»
BEA/Weblogic
Author
Getting Server Name if the Current Managed Server on a Cluster Env
V Hs
Greenhorn
Joined: Dec 18, 2010
Posts: 1
posted
Dec 18, 2010 13:48:51
0
I need to get the Server Name of the Current Managed Server on which currently i m in.
Bhagat Singh Rawat
Ranch Hand
Joined: Apr 04, 2009
Posts: 93
posted
Dec 19, 2010 15:36:27
0
V Hs wrote:
I need to get the Server Name of the Current Managed Server on which currently i m in.
If you are using Weblogic server, here is an example:
import weblogic.management.*; public static String getIpAddOfCurrSrv() { ServerRuntimeMBean serverRuntime = null; Set mbeanSet = null; Iterator mbeanIterator = null; String ipAddress = ""; String adminServerUrl="t3://localhost:7001"; try { MBeanHome mBeanHome = null; mBeanHome = Helper.getAdminMBeanHome("user", "password", adminServerUrl) ; mbeanSet = mBeanHome.getMBeansByType("ServerRuntime"); if(mbeanSet != null){ mbeanIterator = mbeanSet.iterator(); while (mbeanIterator.hasNext()) { serverRuntime = (ServerRuntimeMBean) mbeanIterator.next(); if(serverRuntime != null){ ipAddress = serverRuntime.getURL("HTTP") ; return ipAddress; } } } } catch (Exception e) {} return ipAddress; }
Brainbench Java 2.0 Fundamentals, J2EE 1.4
http://www.brainbench.com/transcript.jsp?pid=8192792
T. Huy Nguyen
Ranch Hand
Joined: Nov 02, 2010
Posts: 57
posted
Dec 20, 2010 18:43:04
0
(WLS10.3) Although the blow code uses the deprecated class MBeanHome, it is still working well
String serverName = null; try { InitialContext myCtx = new InitialContext(); MBeanHome mbeanHome = (MBeanHome) myCtx.lookup("weblogic.management.home.localhome"); serverName = mbeanHome.getMBeanServer().getServerName(); } catch (Exception e) { throw new JspException (e); } if (serverName == null) serverName = ""; getJspContext().getOut().println(serverName);
My material for
SCJP
(2008),
SCWCD
(2010),
SCBCD
(2010).
About me
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Getting Server Name if the Current Managed Server on a Cluster Env
Similar Threads
NodeManager problem
Doubt on PersistenceContext
are Initialcontext objects are replicated while clustering
Managed server instance name
How to retrieve managed server name using Java?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter