Log4j 2
  1. Log4j 2
  2. LOG4J2-716

Auto-disable JMX when detecting Android

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.1
    • Component/s: JMX
    • Labels:
      None

      Description

      During the investigation of LOG4J2-703 we discovered that on Android's Dalvik VM, Log4J2's JMX components cannot be initialized.

      This can be worked around by setting system property log4j2.disable.jmx=true.

      This ticket is to automatically set that system property when detecting that Log4j is running on Android.

      TODO investigate if JMX is not supported at all on that environment or whether it can be made to work if invoked correctly. UPDATE: java.lang.management is not supported as of Android API level 20. See http://developer.android.com/reference/packages.html

      Stack trace:

      07-15 15:12:52.539    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.539    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.543    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve interface method 926: Ljavax/management/MBeanServer;.registerMBean (Ljava/lang/Object;Ljavax/management/ObjectName;)Ljavax/management/ObjectInstance;
      07-15 15:12:52.543    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.543    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.547    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.547    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.547    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.547    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.547    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.551    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.551    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.551    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.551    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.555    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.555    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.555    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.555    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.555    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.559    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.559    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.559    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.559    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.559    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/ObjectName;)
      07-15 15:12:52.563    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.563    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Unable to resolve superclass of Lorg/apache/logging/log4j/core/jmx/StatusLoggerAdmin; (391)
      07-15 15:12:52.563    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Link of class 'Lorg/apache/logging/log4j/core/jmx/StatusLoggerAdmin;' failed
      07-15 15:12:52.563    1603-1603/com.torointl.log4j2xtest E/dalvikvm﹕ Could not find class 'org.apache.logging.log4j.core.jmx.StatusLoggerAdmin', referenced from method org.apache.logging.log4j.core.jmx.Server.registerStatusLogger
      07-15 15:12:52.567    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve new-instance 764 (Lorg/apache/logging/log4j/core/jmx/StatusLoggerAdmin;) in Lorg/apache/logging/log4j/core/jmx/Server;
      07-15 15:12:52.567    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve static method 456: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer ()Ljavax/management/MBeanServer;
      07-15 15:12:52.571    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.571    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.571    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Unable to resolve superclass of Lorg/apache/logging/log4j/core/jmx/LoggerContextAdmin; (391)
      07-15 15:12:52.571    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Link of class 'Lorg/apache/logging/log4j/core/jmx/LoggerContextAdmin;' failed
      07-15 15:12:52.575    1603-1603/com.torointl.log4j2xtest E/dalvikvm﹕ Could not find class 'org.apache.logging.log4j.core.jmx.LoggerContextAdmin', referenced from method org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure
      07-15 15:12:52.575    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve new-instance 759 (Lorg/apache/logging/log4j/core/jmx/LoggerContextAdmin;) in Lorg/apache/logging/log4j/core/jmx/Server;
      07-15 15:12:52.575    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.575    1603-1603/com.torointl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.management.ObjectName', referenced from method org.apache.logging.log4j.core.jmx.Server.unregisterAllMatching
      07-15 15:12:52.579    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve new-instance 393 (Ljavax/management/ObjectName;) in Lorg/apache/logging/log4j/core/jmx/Server;
      07-15 15:12:52.579    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.579    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.579    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.583    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.583    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.583    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.583    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.587    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.587    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.587    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.587    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.587    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.591    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.591    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.591    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve static method 456: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer ()Ljavax/management/MBeanServer;
      07-15 15:12:52.595    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.599    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.603    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.607    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.611    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.615    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.615    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.619    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.623    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.627    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve static method 456: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer ()Ljavax/management/MBeanServer;
      07-15 15:12:52.631    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.635    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.639    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.643    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.647    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.651    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.651    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.655    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.659    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.663    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.671    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/management/MBeanServer;)
      07-15 15:12:52.675    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Unable to resolve superclass of Lorg/apache/logging/log4j/core/jmx/StatusLoggerAdmin; (391)
      07-15 15:12:52.675    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Link of class 'Lorg/apache/logging/log4j/core/jmx/StatusLoggerAdmin;' failed
      07-15 15:12:52.683    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Unable to resolve superclass of Lorg/apache/logging/log4j/core/jmx/LoggerContextAdmin; (391)
      07-15 15:12:52.683    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Link of class 'Lorg/apache/logging/log4j/core/jmx/LoggerContextAdmin;' failed
      07-15 15:12:52.695    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d72b20)
      07-15 15:12:52.715    1603-1603/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
          Process: com.torointl.log4j2xtest, PID: 1603
          java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory
                  at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:118)
                  at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:369)
                  at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:416)
                  at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)
                  at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
                  at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                  at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                  at com.torointl.log4j2xtest.MyActivity.onCreate(MyActivity.java:28)
                  at android.app.Activity.performCreate(Activity.java:5231)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                  at android.app.ActivityThread.access$800(ActivityThread.java:135)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:136)
                  at android.app.ActivityThread.main(ActivityThread.java:5017)
                  at java.lang.reflect.Method.invokeNative(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:515)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                  at dalvik.system.NativeStart.main(Native Method)
      

        Issue Links

          Activity

          Hide
          Remko Popma added a comment -

          Modified solution to avoid dependence on system properties. The new solution is to catch and ignore any Throwable when configuring the JMX MBeans.

          Fixed in revision 1611020.
          Please verify and close.

          Show
          Remko Popma added a comment - Modified solution to avoid dependence on system properties. The new solution is to catch and ignore any Throwable when configuring the JMX MBeans. Fixed in revision 1611020. Please verify and close.
          Hide
          Remko Popma added a comment -

          Fixed in revision 1611003.
          Please verify and close.

          Show
          Remko Popma added a comment - Fixed in revision 1611003. Please verify and close.

            People

            • Assignee:
              Remko Popma
              Reporter:
              Remko Popma
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development