6 Accessing Custom MBeans

This chapter describes ways to access your custom MBeans by means other than programmatic JMX access to them. You can use any JMX-compliant management system to access your MBeans. See the Oracle Technology Network Web site, which provides links to books, white papers, and other information on JMX: http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html.

This chapter includes the following sections:

Accessing Custom MBeans from JConsole

The JDK includes JConsole, a Swing-based JMX client that you can use to browse MBeans. You can browse the MBeans in any WebLogic Server MBean server and in the JVM platform MBean server.

Oracle recommends that you use JConsole only in a development environment; it consumes significant amounts of resources. See Using JConsole to Monitor Applications at http://www.oracle.com/technetwork/articles/java/jconsole-1564139.html. Also, see Managing WebLogic Servers With JConsole at https://blogs.oracle.com/WebLogicServer/entry/managing_weblogic_servers_with.

To access custom MBeans from JConsole:

  1. If wljmxclient.jar and wlclient.jar are not in the JConsole classpath:

    1. Enable the IIOP protocol for the WebLogic Server instance that hosts your MBeans.

    2. Configure the default IIOP user to be a WebLogic Server user with Administrator privileges. In this scenario, the login and password you provide in Step 5d or Step 6d is irrelevant, and the default IIOP user will be associated with each request.

    See Enable and Configure IIOP in the Oracle WebLogic Server Administration Console Online Help.

    If wljmxclient.jar and wlclient.jar are in the JConsole classpath, there is no need to enable the default IIOP user. Go to Step 2.

    Note:

    wlclient.jar is included in wljmxclient.jar's MANIFEST ClassPath entry, so wlclient.jar and wljmxclient.jar need to be in the same directory, or both jars need to be specified on the classpath.

    Ensure that weblogic.jar or wlfullclient.jar is not included in the classpath if wljmxclient.jar is included. Only the thin client wljmxclient.jar/wlclient.jar or the thick client wlfullclient.jar should be used, but not a combination of both.

  2. From a command prompt, make sure that the JDK is on the path.

  3. JConsole can be invoked with either wljmxclient.jar or weblogic.jar in the JConsole classpath.

    • To start JConsole with wljmxclient.jar in the classpath:

      Unix:

      $ jconsole -J-Djava.class.path=$JAVA_HOME/lib/jconsole.jar:$ORACLE_HOME/wlserver/server/lib/wljmxclient.jar
      

      Windows:

      c:> jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%ORACLE_HOME%\wlserver\server\lib\wljmxclient.jar
      
    • To start JConsole with weblogic.jar in the classpath:

      Unix:

      $ jconsole -J-Djava.class.path=$JAVA_HOME/lib/jconsole.jar:$ORACLE_HOME/wlserver/server/lib/weblogic.jar
      

      Windows:

      c:> jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%ORACLE_HOME%\wlserver\server\lib\weblogic.jar

    Note:

    Note the following:

    • You must explicitly set the classpath using -J-Djava.class.path=option. The current classpath is not taken by JConsole.

    • If your configuration is as described in Step 4, you can start JConsole simply by executing the command jconsole. If you start JConsole this way, however, only the user who started the WLS process can connect locally.

  4. If your custom MBeans are registered in the JVM platform MBean server (or if you have configured the WebLogic Server Runtime MBean Server to be the JVM platform MBean server) and you are running JConsole on the same machine as your WebLogic Server instance:

    1. In the JConsole window, select Connection, and click New Connection.

    2. In the New Connection window, select the Local Process tab, select WebLogic.Server, and click Connect.

  5. If your custom MBeans are registered in the WebLogic Server Runtime MBean Server:

    1. In the JConsole window, select Connection, and click New Connection.

    2. In the New Connection window, select the Remote Process option.

    3. In the Remote Process JMX URL text box, enter the following:

      service:jmx:iiop://host:port/jndi/weblogic.management.mbeanservers.runtime
      

      where host:port represents the host name and port of the WebLogic Server instance that hosts your MBeans. For example, localhost:7001.

    4. In the User Name and Password fields, enter the user name and password of any user account that is assigned the administrator role. This login will be used to authenticate the client and create the Subject that will be associated with each JMX request coming from the client.

    5. Click Connect.

  6. If your custom MBeans are registered in the WebLogic Server Domain Runtime MBean Server:

    1. In the Console window, select Connection, and click New Connection.

    2. In the New Connection window, select the Remote Process option.

    3. In the Remote Process JMX URL text box, enter the following:

      service:jmx:iiop://host:port/jndi/weblogic.management.mbeanservers.domainruntime
      

      where host:port represents the host name and port of the WebLogic Server instance that hosts your MBeans. For example, localhost:7001.

    4. In the User Name and Password fields, enter the user name and password of any user account that is assigned the administrator role. This login will be used to authenticate the client and create the Subject that will be associated with each JMX request coming from the client.

    5. Click Connect.

Accessing Custom MBeans from WebLogic Scripting Tool

If you register your MBeans in the Runtime MBean Server or Domain Runtime MBean Server, you can use WebLogic Scripting Tool to access your custom MBeans. See Accessing Other WebLogic MBeans and Custom MBeans in Understanding the WebLogic Scripting Tool.

Accessing Custom MBeans from an Administration Console Extension

You can extend the WebLogic Server Administration Console by creating Java Server Pages (JSPs) that conform to a specific template. Your JSP can include JMX code that connects to the JVM platform MBean server, the WebLogic Server Runtime MBean Server, or the Domain Runtime MBean Server and looks up your MBeans.