Search code examples
javaweblogicjmx

Weblogic MBean Server remote connection via JMXConnectorFactory (t3 protocol)


Im trying to view the available MBeans in order to come up with a solution (access adminserver jmx and monitor sessions/connections/etc. of all other servers in the domain). Weblogic server is running on a remote server.

The idea is to create a java script which connects to the JMX, reads the domain and finds the connected servers, export the list of connected server to a monitoring tool and then every x minutes ping Weblogics mbean server and find out the needed params for each server within the domain. Yet when I try creating a connection to the Weblogic JMX, im hitting a "infinite loop" which I assume that means a connection is repetitively trying to be made unsuccessfully.

The admin server has been given these params (start up):

-XX:+UnlockCommercialFeatures 
-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=9001
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.rmi.port=9001

I have:

  • locally installed WLS version : fmw_14.1.1.0.0_wls_lite_quick_generic
  • added wlthint3client.jar to classpath within IDEA
  • tried checking the firewall by pinging the IP:PORT via telnet in cmd, the port is definitely open

Method creating a connection to JMX:

    String protocol = "t3";
    String jndiroot = "/jndi/";
    String mBeanServer = "weblogic.management.mbeanservers.domainruntime";

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

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

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

        System.out.println("MAKING JMX CONNECTION...");
        connector = JMXConnectorFactory.connect(serviceURL, hashtable);
        System.out.println("JMX CONNECTION MADE...");
        return connector;
    }

Only the first print is executed...

When performing a connection to service:jmx:rmi:///jndi/rmi://<WLS_IP>:9001/jmxrmi everything works fine, however this is not a connection to the MBean Server, meaning I dont have access to the required MBeans for monitoring the server domain and its traffic.


Solution

  • Add the following JVM Property to your server instance to get access to WebLogic's mbeans :

    -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder