You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2018/01/16 20:24:00 UTC

[jira] [Resolved] (DBCP-482) Avoid javax.management.InstanceNotFoundException on shutdown when a bean is not registered

     [ https://issues.apache.org/jira/browse/DBCP-482?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory resolved DBCP-482.
-------------------------------
       Resolution: Fixed
    Fix Version/s: 2.2.1

In git master. Please verify and close. Do you see any other issues in the JMX area?

> Avoid javax.management.InstanceNotFoundException on shutdown when a bean is not registered
> ------------------------------------------------------------------------------------------
>
>                 Key: DBCP-482
>                 URL: https://issues.apache.org/jira/browse/DBCP-482
>             Project: Commons Dbcp
>          Issue Type: Improvement
>    Affects Versions: 2.0.1, 2.1.1, 2.2.0
>         Environment: Spring Framework 4.3.11.RELEASE
> Java 1.8.0.121-b13
> MacOS Sierra
>            Reporter: Dennis Lloyd
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 2.2.1
>
>
> When using DBCP2 with JMX, the following warning is presented upon shutting down a Spring Application Context:
> {code}
> javax.management.InstanceNotFoundException: org.apache.commons.dbcp2:name=crawlDataSource,type=BasicDataSource
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095) ~[na:1.8.0_121]
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:427) ~[na:1.8.0_121]
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415) ~[na:1.8.0_121]
> 	at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:546) ~[na:1.8.0_121]
> 	at org.apache.commons.dbcp2.BasicDataSource.close(BasicDataSource.java:1941) ~[commons-dbcp2-2.2.0.jar:2.2.0]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
> 	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
> 	at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:364) [spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:287) [spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) [spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) [spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) [spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) [spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:230) [spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) [spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030) [spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006) [spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> 	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) [spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]
> {code}
> It appears that JMX begins unregistering before the connection is closed, as evidenced by the following logs that appear shortly before the one above:
> {code}
> 2017-Dec-27-11:34:48.330 [main] INFO  o.s.j.e.a.AnnotationMBeanExporter - Unregistering JMX-exposed beans on shutdown
> 2017-Dec-27-11:34:48.330 [main] INFO  o.s.j.e.a.AnnotationMBeanExporter - Unregistering JMX-exposed beans
> {code}
> The following code block in the close() method is the source of the warning: 
> {code}
>         if (registeredJmxName != null) {
>             MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
>             try {
>                 mbs.unregisterMBean(registeredJmxName);
>             } catch (JMException e) {
>                 log.warn("Failed to unregister the JMX name: " + registeredJmxName, e);
>             } finally {
>                 registeredJmxName = null;
>             }
>         }
> {code}
> Would it be safe if the code instead silently ignored an InstanceNotFoundException?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)