java - Failed to Unregister DataSource JMX MBean While Shutting Down a Spring Boot Application -


I have an application using a simple spring boot org.apache.commons.dbcp2.BasicDataSource data source beans .

The data source is automatically exposed as a MBean by Spring Boot

Bean Announcement: @in Public Data Source Data Source () {Basic data source data source = new basic data source (); DataSource.setUrl (dbUrl); DataSource.setDriverClassName (jdbcDriver); DataSource.setUsername (dbUserName); DataSource.setPassword (dbPassword); Return data source; }

Everything works fine though, I see an error while closing the application. This error occurs when the running jar runs. Gradle use Spring plugin (Gradle bootRun), so it is not shown

  javax.management.InstanceNotFoundException :. Org.apache.commons.dbcp2: Name = Data Source, BasicDataSource at .jmx.interceptor.DefaultMBeanServerInterceptor.getMBean (DefaultMBeanServerInterceptor.java:1095) at com.sun com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean (DefaultMBeanServerInterceptor. Java: 427) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean (on DefaultMBeanServerInterceptor.java): 415) com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean (JmxMBeanServer.java read 46) org.apache.commons.dbcp2 .BasicDataSource.close (BasicDataSource.java:1822) at sun.reflect.NativeMethodAccessorImpl.invoke0 (at least the native resident method) sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl .java: 43) java.lang.reflect.Method.invoke at on (Method.java:483) Org.springframework on Bean s.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod (DisposableBeanAdapter.java:350) (Dispojheblbana adapter at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy. Java .73) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry Org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton (DefaultListableBeanFactory.java:827) on org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton (DefaultSingletonBeanRegistry.java Article 16) on deleted bean (DefaultSingletonBeanRegistry.java) Org Org.springframework.context.support.AbstractApplicationContext at org.springframework.context.support.AbstractApplicationContext.destroyBeans (at AbstractApplicationContext.java:921) on .springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons (org.springframework.doc) (DefaultSingletonBeanRegistry.java:485) .doClose (AbstractApplicationContext.java:895) org.springframework.boot.context.embedded.Embedde dWebApplicationContext.doClose (EmbeddedWebApplicationContext.java:152) org.springframework.context.support.AbstractApplicationContext $ 1. Run (AbstractApplicationContext.java:809)   

I'm thinking, 1. How does it be exposed in the form of Bean Jmx MBN? 2. How to properly cancel the MBean registration

Spring BasicDataSource trying to stop two bar:

  • uses the default methods for closing spring Datastore, but before closing

    it avoid it use:

    1.   @ Bean (destroyMethod = "") public data source data source ()   

      Java configuration

  • Comments

    Popular posts from this blog

    ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

    Matlab transpose a table vector -

    c# - Textbox not clickable but editable -