Search code examples
javaspringspring-bootspring-jmx

Spring boot devtools fails to restart the application


I am using Spring Boot 1.5.6 with devtools support. But when I change, the devtools will try restarting the code. Which is throwing Failed to unregister LiveBeansView MBean; nested exception is javax.management.InstanceNotFoundException error.

Stack trace:

14:12:00.433 [Thread-11] WARN  o.s.c.a.AnnotationConfigApplicationContext - Exception thrown from ApplicationListener handling ContextClosedEvent
org.springframework.context.ApplicationContextException: Failed to unregister LiveBeansView MBean; nested exception is javax.management.InstanceNotFoundException: DefaultDomain:application=/tenancy
    at org.springframework.context.support.LiveBeansView.unregisterApplicationContext(LiveBeansView.java:89)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:985)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:956)
    at org.springframework.boot.builder.ParentContextCloserApplicationListener$ContextCloserListener.onApplicationEvent(ParentContextCloserApplicationListener.java:102)
    at org.springframework.boot.builder.ParentContextCloserApplicationListener$ContextCloserListener.onApplicationEvent(ParentContextCloserApplicationListener.java:86)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:989)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:956)
    at org.springframework.boot.devtools.restart.Restarter.stop(Restarter.java:321)
    at org.springframework.boot.devtools.restart.Restarter$2.call(Restarter.java:258)
    at org.springframework.boot.devtools.restart.Restarter$2.call(Restarter.java:254)
    at org.springframework.boot.devtools.restart.Restarter$LeakSafeThread.run(Restarter.java:627)
Caused by: javax.management.InstanceNotFoundException: DefaultDomain:application=/tenancy
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(Unknown Source)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(Unknown Source)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(Unknown Source)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(Unknown Source)
    at org.springframework.context.support.LiveBeansView.unregisterApplicationContext(LiveBeansView.java:86)
    ... 14 common frames omitted

Solution

  • I could resolve the problem: This is happening because the spring.jmx is enabled. Even you set the application properties as spring.jmx.enabled=false, it does not work. Because If you run the application as Spring Boot App. It is automatically enabled by STS.

    Solution Turn the apring.jmx.enabled off from Boot Dashboard. By select project>click pencil (edit)>uncheck enable JMX.

    enter image description here