JMX registration of MailServer can fail if the MBean already exists

XMLWordPrintable

      Confluence prints the following error when starting up:

      SEVERE: Exception starting filter jmx
          org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean
          [com.atlassian.confluence.jmx.JmxSMTPMailServer@199ec67[id=1208645280823,name=SMTP Server,description=<null>,
          server name=<null>,username=confluence@veil.org.ua,password=qwerty,isSessionServer=true,
          defaultFrom=confluence@veil.org.ua,prefix=[confluence],smtpPort=465]] with object name 
          [Confluence:name=MailServer-SMTP Server]; nested exception is javax.management.InstanceAlreadyExistsException:
          Confluence:name=MailServer-SMTP Server
      Caused by: javax.management.InstanceAlreadyExistsException: Confluence:name=MailServer-SMTP Server
      at com.sun.jmx.mbeanserver.Repository.addMBean(Unknown Source)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(Unknown Source)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(Unknown Source)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(Unknown Source)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(Unknown Source)
      at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(Unknown Source)
      at org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(MBeanRegistrationSupport.java:162)
      at org.springframework.jmx.export.MBeanExporter.registerManagedResource(MBeanExporter.java:431)
      at com.atlassian.confluence.jmx.MBeanExporterWithUnregisterImpl.registerManagedResource(MBeanExporterWithUnregisterImpl.java:93)
      at com.atlassian.confluence.jmx.JmxFilter.registerObject(JmxFilter.java:164)
      at com.atlassian.confluence.jmx.JmxFilter.doMailServer(JmxFilter.java:87)
      at com.atlassian.confluence.jmx.JmxFilter.registerBeans(JmxFilter.java:63)
      at com.atlassian.confluence.jmx.JmxFilter.init(JmxFilter.java:42)
      

      There are two issues to consider here:

      1) Why does the MBean already exist? It should not be registered twice during startup.

      2) If it does exist, we probably shouldn't stop the entire application from starting up. The existence should be checked before registration and it should recover from this error gracefully.

            Assignee:
            Brian Nguyen (Inactive)
            Reporter:
            Andrew Lynch (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: