Tomcat and MBeanTrustPermission

May 28, 2009

Here’s a problem a savvy web developer might run into. If you have a war that exports MBeans for JMX, upon dropping this war into Tomcat you may run into this nasty exception:

java.security.AccessControlException: access denied (javax.management.MBeanTrustPermission register)

This is caused by an overrestrictive security policy. Edit conf/catalina.policy to include this line:

grant {
permission javax.management.MBeanTrustPermission “register”;
};

Then add to your CATALINA_OPTS the following VM argument:

-Djava.security.policy=<path to catalina.policy>

I’m not sure if there’s a way to have Tomcat read in catalina.policy automatically, but if there is, I haven’t figured it out yet.