In the project, Druid is used to manage the database connection pool. There is no problem in the local and test environment. However, after the production environment, when Tomcat is started for the first time, the log does not report an error, but the page can’t come out. When Tomcat is closed, you can see the log and find that the error is as follows:
ERROR [ com.alibaba.druid . stat.DruidDataSourceStatManager ] – unregister mbean error
javax.management.InstanceNotFoundException : com.alibaba.druid :type=DruidDataSourceStat
at com.sun.jmx . interceptor.DefaultMBeanServerInterceptor .getMBean………
Various methods have been found on the Internet, but they are all vague. After many tests, the solution is as follows:
Modify the bin directory of Tomcat catalina.sh File in OS specific support. $var_ must_ Be set to either true or false
JAVA_ OPTS=”- Ddruid.registerToSysProperty=true “OK, as shown in the figure:
After tomcat, just start the deployment project once and don’t report this error again.