Lately at work we’ve been using the tomcat plugin for our gradle projects instead of the bundled jetty plugin. There were a lot of reasons for doing this with the main reason being our production environment for our current project is tomcat so it makes sense to have an embedded server that mirrors that environment. I had already devoted time getting JMX working with the jetty plugin, so today I investigated doing the same with the tomcat plugin.
Luckily this is one of those cases where “it just works.” Well, almost. You’ll need to add the following properties to the GRADLE_OPTS environment variable.
That’s it. Now when you you fire up tomcatRun you can open up jconsole and navigate to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi and you’re good to go.