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)
Attachments
Issue Links
- supercedes
-
LOG4J2-703 Android: Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
- Resolved