2 Replies Latest reply on Mar 4, 2012 11:50 PM by Steve Button-Oracle

    How to dynamically get managed instance name using Java?

      I deployed a web application to 2 different managed instances A & B. Inside the web application, I want to get the managed server instance that it's deployed to. For example, if it's deployed to A then I'll get back A.

      How do I dynamically find out name of the managed instance using Java?


      I'm using WL 10.3.5
        • 1. Re: How to dynamically get managed instance name using Java?
          Pierluigi Vernetto
          System.getProperty("weblogic.Name") might do the trick...

          uppercase N in Name!
          • 2. Re: How to dynamically get managed instance name using Java?
            Steve Button-Oracle
            There's also a non-public class (and therefore something I can't endorse ... ) weblogic.rjvm.JVMID which contains a set of data about where the server is running. If you looked at it, you'd see that it exposes information about where the server is running, including the domain name, the server name, the hostname, etc.
            public final class weblogic.rjvm.JVMID {
                public java.lang.String getHostAddress();
                public final java.lang.String getClusterAddress();
                public final int getPublicPort();
                public final java.lang.String getPublicAddress();
                public java.lang.String getDomainName();
                public java.lang.String getDNSName();
                public java.lang.String getServerName();
            The System property mentioned here works too and relying on that doesn't introduce a code dependency on an internal WLS class. But the JVMID class does have useful information.

            Now to just make the point again, this is not a public API so it'd be user beware if you used it.