Plugins You can find out about all the publicly available Grails plugins.

JMX Plugin

  • Tags: performance, utility
  • Latest: 0.9
  • Last Updated: 31 October 2013
  • Grails version: 2.0 > *
5 votes
compile "org.grails.plugins:jmx:0.9"

 Documentation  Source  Issues


Adds JMX support and provides the ability to expose services and other Spring beans as MBeans


JMX Plugin

This plugin adds JMX MBeanServer support through Spring.

Plugin features:

  • Configures MBeanServer in Grails Application
  • Registers services with JMX which are singletons that include the "expose" property, e.g. "static expose = ['jmx']"
  • Provides default object naming {appname}:service=${serviceName},type=service
  • Allows for object name override: static expose = ['jmx:service=Country,type=special']
  • Allows for exclusion map: static jmxexpose = ['excludeMethods':'isTransactional,setTransactional,getTransactional,getJmxexpose,setJmxexpose,getExpose,setExpose']
  • Checks to see if Hibernate is a plugin and if so it exposes the Hibernate Statistics MBean
  • Exposes the Log4j MBean for runtime logging level configuration
  • Exposes the Grails DataSource as an MBean
  • Allows for any spring bean to be exposed through Config.groovy or with Spring @ManagedResource annotation


There is nothing to do after the install if you have no services to expose. Just run the application and use a JMX tool such as jconsole to administer.

To be able to connect to the exposed services (which also includes the ones made available by the plugin by default) you have to set the system property before running your app.

Exposing Services

By default, the plugin only supports exposing Services. This is accomplished by add 'jmx' to the static expose property as outlined below:

class StateService {

static expose = ['jmx'] … }

This will expose the service using a convention for the service name. Alternatively you can be explicit as in the following example:

class CountryService {

static expose = ['jmx:service=Country,type=special'] … }

Exposing Spring Beans

The plugin also supports exposing other Spring Beans - e.g. registered via resources.groovy . This is accomplished by adding 'jmx' to the static expose property as outlined above and using the following code in @[email protected]

grails {
   jmx {
      exportBeans = ['myBean']

You can also annotate the class with @ManagedResource, for example

import org.springframework.jmx.export.annotation.ManagedAttribute
import org.springframework.jmx.export.annotation.ManagedResource

@ManagedResource class MyBean {

private int count

void setClickCount(int c) { count = c }

@ManagedAttribute int getClickCount() { count } }


By default the domain for your beans is the application name, but you can override this in Config.groovy, e.g.

grails.plugin.jmx.domain = 'MyDomain'