I want to deploy deploy spring-boot application to external tomcat with security manager enabled. The Jndi is configured in tomcat with the name jdbc/abc .The tomcat asks for some permissions when I deploy, which I grant in the catalina.policy of the tomcat. I am presently getting some access denied message as shown below.
org.apache.tomcat.jdbc.pool.jmx.JmxUtil.registerJmx Jmx registration failed.
java.security.AccessControlException: access denied ("javax.management.MBeanPermission" "org.apache.tomcat.jdbc.pool.PooledConnection#-[tomcat.jdbc:class=org.apache.tomcat.jdbc.pool.DataSource,connections=PooledConnection[0],name="jdbc/abc",type=ConnectionPool]" "registerMBean")
I then granted permission as
permission javax.management.MBeanPermission "org.apache.tomcat.jdbc.pool.PooledConnection#-[tomcat.jdbc:class=org.apache.tomcat.jdbc.pool.DataSource,connections=PooledConnection[0],name=jdbc/abc ,type=ConnectionPool]", "registerMBean";
then again the message repeats in the server output, I am not sure whether I granted this permission in the right way? Can anyone suggest me where I am doing wrong?
The server configuration for connection pool is as shown below:
<Resource name="jdbc/abc"
type="javax.sql.DataSource"
url="url to the database"
username="MyName"
password="123"
/>
This should probably be considered a bug in the Tomcat JDBC library: a
DataSourceprovided by the container should useAccessController.doPriviledgedto perform JMX operations. It also should provide a set of permissions to regulate access from application code to theDataSource. However since theSecurityManagerwill probably be deprecated (cf. JEP 411) I doubt that this bug will ever be resolved.Since Tomcat JDBC registers lots of JMX beans, I would give to all the
org.tomcat.jdbcclasses permission to register any MBean in thetomcat.jdbcdomain:The
MBeanPermissionis granted using the:(cf. Javadoc), where:
registerMBeanaction,ObjectNamepattern (cf. Javadoc): in your case all names in thetomcat.jdbcdomain,You can also try more restrictive
ObjectNames, e.g.tomcat.jdbc:name=jdbc/abc,*to restrict the permission to one datasource only.Remark: If you don't intend to use JMX to monitor your datasource performance you can also use
jmxEnabled="false"(cf. documentation) and all permission problems will go away.