Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3121

log4j2 config modified at run-time may trigger incomplete MBean re-initialization due to InstanceAlreadyExistsException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.14.1
    • None
    • Core
    • None

    Description

      We occasionally encounter an InstanceAlreadyExistsException during log4j2 reconfiguration after update to the configuration file at run-time. This causes the MBean initialization to be incomplete.

      The exception can be suppressed by checking whether the MBean is registered and de-registering it first. I will provide a pull request.

      2021-07-09 14:37:37,961 Log4j2-TF-1-ConfiguratonFileWatcher-3 ERROR Could not register mbeans javax.management.InstanceAlreadyExistsException: org.apache.logging.log4j2:type=5c29bfd
       at java.management/com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:436)
       at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1855)
       at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:955)
       at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:890)
       at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:320)
       at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
       at org.apache.logging.log4j.core.jmx.Server.register(Server.java:393)
       at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:168)
       at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:141)
       at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:638)
       at org.apache.logging.log4j.core.LoggerContext.onChange(LoggerContext.java:763)
       at org.apache.logging.log4j.core.util.AbstractWatcher$ReconfigurationRunnable.run(AbstractWatcher.java:93)
       at java.base/java.lang.Thread.run(Thread.java:834)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              spannjp Markus Spann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: