tomcat8.5生产环境报错javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat

tv6aics1  于 2022-10-22  发布在  Java
关注(0)|答案(6)|浏览(455)

tomcat 部署到生产环境报错如下,服务器是windows系统,网上搜了说要在tomcat的catalina.bat中配置一个参数set JAVA_OPTS="-Ddruid.registerToSysProperty=true" 但是我配了 还是报错,但是不影响功能使用,隔一段时间就报一次。
参数配置在文件的最后面,如下
%_EXECJAVA% %LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% %JPDA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
goto end
:doSecurityJpda
%_EXECJAVA% %LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% %JPDA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
goto end
set JAVA_OPTS="-Ddruid.registerToSysProperty=true"
:end

异常堆栈信息如下
2017-09-05 10:08:27.141 [] [] [] ERROR [localhost-startStop-2] <com.alibaba.druid.stat.DruidDataSourceStatManager.removeDataSource(DruidDataSourceStatManager.java:211)> unregister mbean error
javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:427)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415)
at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:546)
at com.alibaba.druid.stat.DruidDataSourceStatManager.removeDataSource(DruidDataSourceStatManager.java:209)
at com.alibaba.druid.pool.DruidDataSource$2.run(DruidDataSource.java:1562)
at java.security.AccessController.doPrivileged(Native Method)
at com.alibaba.druid.pool.DruidDataSource.unregisterMbean(DruidDataSource.java:1558)
at com.alibaba.druid.pool.DruidDataSource.close(DruidDataSource.java:1517)
at com.jfinal.plugin.druid.DruidPlugin.stop(DruidPlugin.java:186)
at com.jfinal.core.JFinal.stopPlugins(JFinal.java:112)
at com.jfinal.core.JFinalFilter.destroy(JFinalFilter.java:95)
at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:318)
at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4623)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5421)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1435)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1424)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
2017-09-05 10:08:27.148 [] [] [] ERROR [localhost-startStop-2] <com.alibaba.druid.stat.DruidStatService.unregisterMBean(DruidStatService.java:376)> unregister mbean error
javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidStatService
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:427)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415)
at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:546)
at com.alibaba.druid.stat.DruidStatService.unregisterMBean(DruidStatService.java:374)
at com.alibaba.druid.stat.DruidDataSourceStatManager.removeDataSource(DruidDataSourceStatManager.java:214)
at com.alibaba.druid.pool.DruidDataSource$2.run(DruidDataSource.java:1562)
at java.security.AccessController.doPrivileged(Native Method)
at com.alibaba.druid.pool.DruidDataSource.unregisterMbean(DruidDataSource.java:1558)
at com.alibaba.druid.pool.DruidDataSource.close(DruidDataSource.java:1517)
at com.jfinal.plugin.druid.DruidPlugin.stop(DruidPlugin.java:186)
at com.jfinal.core.JFinal.stopPlugins(JFinal.java:112)
at com.jfinal.core.JFinalFilter.destroy(JFinalFilter.java:95)
at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:318)
at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4623)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5421)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1435)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1424)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

k2arahey

k2arahey1#

打开catalina.sh,在 #OS specific support 。。。。
和cygwin= false 中间增加 JAVA_OPTS="=Dduid.registerToSysProperty=true"
如果有JAVA_OPTS则在后面追加就可以。

rm5edbpk

rm5edbpk2#

打开catalina.sh,在 #OS specific support 。。。。
和cygwin= false 中间增加 JAVA_OPTS="=Dduid.registerToSysProperty=true"
如果有JAVA_OPTS则在后面追加就可以。
究竟是JAVA_OPTS="-Ddruid.registerToSysProperty=true" 还是JAVA_OPTS="=Dduid.registerToSysProperty=true"?

lsmepo6l

lsmepo6l3#

请问怎么解决的?

pexxcrt2

pexxcrt24#

打开catalina.sh,在 #OS specific support 。。。。
和cygwin= false 中间增加 JAVA_OPTS="=Dduid.registerToSysProperty=true"
如果有JAVA_OPTS则在后面追加就可以。
究竟是JAVA_OPTS="-Ddruid.registerToSysProperty=true" 还是JAVA_OPTS="=Dduid.registerToSysProperty=true"?

#865 都试下。。。忘记了

b0zn9rqh

b0zn9rqh5#

打开catalina.sh,在 #OS specific support 。。。。
和cygwin= false 中间增加 JAVA_OPTS="=Dduid.registerToSysProperty=true"
如果有JAVA_OPTS则在后面追加就可以。
究竟是JAVA_OPTS="-Ddruid.registerToSysProperty=true" 还是JAVA_OPTS="=Dduid.registerToSysProperty=true"?

#865 都试下。。。忘记了
都试了 还是不行,但是我发现这个错误可能和tomcat的shutdown有关系,如果使用shutdown关闭 然后启动tomcat就会报这个错,但是直接杀死进程 再启动tomca就不会报这个错。

3mpgtkmj

3mpgtkmj6#

基于你生产应用部署在Windows系统,因此需要在Tomcat的安装目录下找到bin目录下的Tomcat9.0.45w.exe程序(因个人安装的Tomcat程序为准),如

,双击Tomcat9.0.45w.exe打开程序找到Java选项,进行Java Options 参数配置。

然后再次在Windows服务进程中对Tomcat服务进行启动和停止,停止Tomcat服务后可在多个应用程序的日志文件中观察到问题得到解决。

相关问题