3 Replies Latest reply: Jul 18, 2011 10:57 AM by 14513 RSS

    Read out the WebLogic-Version using Java


      I wonder if there is a way to read out the WebLogic-Version during server runtime using Java.

      Any help will be appreciated.


        • 1. Re: Read out the WebLogic-Version using Java
          Pierluigi Vernetto
          http://objectmix.com/weblogic/528079-weblogic-server-9-how-detect-version.html (it's a bit garbled but still readable)

          • 2. Re: Read out the WebLogic-Version using Java
            René van Wijk
            An example
            import javax.management.MBeanServerConnection;
            import javax.management.ObjectName;
            import javax.management.remote.JMXConnector;
            import javax.management.remote.JMXConnectorFactory;
            import javax.management.remote.JMXServiceURL;
            import javax.naming.Context;
            import java.io.IOException;
            import java.util.Hashtable;
            public class SomeTest {
                private String hostname = "hostname";
                private Integer port = 7001;
                private String username = "username";
                private String password = "password";
                private String protocol = "t3";
                private String jndiRoot = "/jndi/";
                private String mBeanServer = "weblogic.management.mbeanservers.domainruntime";
                private String serviceName = "com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean";
                private JMXConnector connector;
                public static void main(String[] args) {
                    SomeTest test = new SomeTest();
                    try {
                        MBeanServerConnection connection = test.getMBeanServerConnection();
                    } catch (Exception e) {
                public void getSomeInformation(MBeanServerConnection connection) throws Exception {
                    ObjectName service = new ObjectName(serviceName);
                    ObjectName[] serverRunTimes = (ObjectName[]) connection.getAttribute(service, "ServerRuntimes");
                    for (int i = 0; i < serverRunTimes.length; i++) {
                        String name = (String) connection.getAttribute(serverRunTimes, "Name");
            String version = (String) connection.getAttribute(serverRunTimes[i], "WeblogicVersion");
            String state = (String) connection.getAttribute(serverRunTimes[i], "State");
            System.out.println("Server name: " + name + ", Version: " + version + ", Server state: " + state);

            public MBeanServerConnection getMBeanServerConnection() throws IOException {
            return getJmxConnector().getMBeanServerConnection();

            public JMXConnector getJmxConnector() throws IOException {
            JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port, jndiRoot + mBeanServer);

            Hashtable hashtable = new Hashtable();
            hashtable.put(Context.SECURITY_PRINCIPAL, username);
            hashtable.put(Context.SECURITY_CREDENTIALS, password);
            hashtable.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");

            connector = JMXConnectorFactory.connect(serviceURL, hashtable);
            return connector;

            public void closeJmxConnector() throws IOException {
            Note that when using the 't3' protocol the wlfullclient.jar must be in the classpath, otherwise you run into the following exception:
            java.net.MalformedURLException: Unsupported protocol: t3
                 at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.java:327)
                 at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:247)
            Information to create a wlfullclient.jar can be found here: http://middlewaremagic.com/weblogic/?p=6193
            Information regarding runtimeMBean can be found here: http://download.oracle.com/docs/cd/E12839_01/apirefs.1111/e13951/core/index.html.
            Open the tree Runtime MBeans, ServerRuntimeMBean and click attributes to see the available attributes (such as Name, WeblogicVersion, State etcetera).
            An example output of the program above:
            Server name: osb_server1, Version: WebLogic Server Fri Apr 9 00:05:28 PDT 2010 1321401 , Server state: RUNNING
            Server name: AdminServer, Version: WebLogic Server Fri Apr 9 00:05:28 PDT 2010 1321401 , Server state: RUNNING
            • 3. Re: Read out the WebLogic-Version using Java

              thank you very much for your help.