淘宝druid报错:javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat

时间:2023-03-09 09:35:21
淘宝druid报错:javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat

问题:

启动tomcat报错:

Tomat报出一下异常:
ERROR [com.alibaba.druid.stat.DruidDataSourceStatManager] – unregister mbean error
javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean………

原因:在一台服务器上启动了两个tomcat,两个tomcat都是用druid。

解决方案:

修改Tomcat 下的 catalina.sh:

增加此句代码: JAVA_OPTS=”-Ddruid.registerToSysProperty=true”

在查找的过程中发现了,在一篇对于开发过程中常见问题的介绍:https://github.com/alibaba/druid/wiki/常见问题