Friday, June 5, 2009

Enabling JMX on a JVM

This is necessary for many of the profiling options, such as allowing a remote JConsole session to connect to a JVM.

I've been profiling my QA WebLogic application because it's been really misbehaving the last two weeks. Sun's free swing app, jconsole, gives a bunch of insight into performance metrics such as memory, garbage collection and object counts.


  1. Enable your JVM to use JConsole

    The jconsole app is enabled via command line parameters that activate at startup. On weblogic you modify the file setDomainEnv.sh in the bin directory of your WL 'domain'. Add the following (Solaris/Unix):

    # Allow JConsole to view this JVM
    JC_JMX_ENAB="-Dcom.sun.management.jmxremote=true"

    # Allow remote access to JConsole at this port
    JC_JMX_PORT="-Dcom.sun.management.jmxremote.port=5097"

    # Don't require login
    JC_JMX_AUTH="-Dcom.sun.management.jmxremote.authenticate=false"

    # Don't require SSL
    JC_JMX_SSL="-Dcom.sun.management.jmxremote.ssl=false "

    JAVA_OPTIONS="${JAVA_OPTIONS} ${JC_JMX_ENAB} ${JC_JMX_PORT} ${JC_JMX_AUTH} ${JC_JMX_SSL}"

    export JAVA_OPTIONS


  2. Restart the WL Server instance or JVM

  3. Start a command line JConsole session on your desktop
    Do this by executing jconsole.exe from the bin directory of your JSDK installation.

  4. Connect to your remote server at the specified JMX port
    Select the 'Remote Process' radio button and enter the host server name and using the port (5097 in this example) in the form [hostname]:[port].


REFERENCES

  1. http://www.javapassion.com/handsonlabs/jconsole/index.html#Configure_a_simple_app
  2. http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html
  3. http://java.sun.com/javase/6/docs/technotes/tools/share/jconsole.html


SEE ALSO

  1. JStat http://java.sun.com/javase/6/docs/technotes/tools/share/jstat.html

No comments:

Post a Comment

Followers