logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johannes Schleger (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-1506) Unregister JMX ignores log4j2.disable.jmx property
Date Tue, 27 Sep 2016 13:05:20 GMT

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

Johannes Schleger updated LOG4J2-1506:
--------------------------------------
    Attachment: 0003-JMX-Server-unregistering-won-t-ignore-log4j2.disable.patch

Catch Throwable similar to Log4j2-716

> Unregister JMX ignores log4j2.disable.jmx property
> --------------------------------------------------
>
>                 Key: LOG4J2-1506
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1506
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: JMX
>    Affects Versions: 2.6.2
>         Environment: Stripped OpenJDK (without java.lang.management)
>            Reporter: Johannes Schleger
>             Fix For: 2.7
>
>         Attachments: 0001-JMX-Server-unregistering-won-t-ignore-log4j2.disable.patch,
0002-JMX-Server-unregistering-won-t-ignore-log4j2.disable.patch, 0003-JMX-Server-unregistering-won-t-ignore-log4j2.disable.patch
>
>
> If java.lang.management is due to security reasons (or anything else) not part of the
JVM, we need so set the JVM Property -Dlog4j2.jmx.disable=true.
> The initialization of the JVM is fine, as the JMX Server class verifies if JMX is disabled.
The Problem is as soon as log4j shuts down, it tries to unregister JMX and ends up with a
NoClassDefFoundError, thus log4j exits abnormally.
> {code:title=Server.java|borderStyle=solid}
> public static void reregisterMBeansAfterReconfigure() {
>         // avoid creating Platform MBean Server if JMX disabled
>         if (isJmxDisabled()) {
>             LOGGER.debug("JMX disabled for log4j2. Not registering MBeans.");
>             return;
>         }
>         final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
>         reregisterMBeansAfterReconfigure(mbs);
>     }
>     public static void unregisterLoggerContext(final String loggerContextName) {
>         final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
>         unregisterLoggerContext(loggerContextName, mbs);
>     }
> {code}
> {code:java}
> 2016-08-09 18:54:06,512 pool-1-thread-1 ERROR Caught exception executing shutdown hook
Shutdown callback for LoggerContext[name=4ee00c09] java.lang.NoClassDefFoundError: java/lang/management/ManagementFactory
> 	at org.apache.logging.log4j.core.jmx.Server.unregisterLoggerContext(Server.java:236)
> 	at org.apache.logging.log4j.core.LoggerContext.stop(LoggerContext.java:300)
> 	at org.apache.logging.log4j.core.LoggerContext$1.run(LoggerContext.java:265)
> 	at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry$RegisteredCancellable.run(DefaultShutdownCallbackRegistry.java:102)
> 	at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.run(DefaultShutdownCallbackRegistry.java:72)
> 	at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.ClassNotFoundException: java.lang.management.ManagementFactory
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
> 	... 6 more
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message