Log4j 2
  1. Log4j 2
  2. LOG4J2-703

Android: Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-rc2
    • Fix Version/s: 2.0, 2.0.1
    • Component/s: None
    • Labels:
      None
    • Environment:

      Android

      Description

      Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

      Am i missing something or is Log4J2 not working yet in an Android environment ?

      MyActivity.java
      import org.apache.logging.log4j.LogManager;
      import org.apache.logging.log4j.Logger;
      
      
      public class MyActivity extends Activity {
      
          static final Logger logger = LogManager.getLogger(MyActivity.class.getName());
      
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_my);
              logger.error("TEST ############################################");
          }
      
      07-08 10:40:23.401    1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
      07-08 10:40:23.441    1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
          Process: com.intl.log4j2xtest, PID: 1307
          java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                  at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                  at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                  at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                  at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                  at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                  at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                  at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                  at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                  at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                  at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                  at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                  at java.lang.Class.newInstanceImpl(Native Method)
                  at java.lang.Class.newInstance(Class.java:1208)
                  at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                  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)
      

      build.gradle file :

      apply plugin: 'com.android.application'
      
      android {
          compileSdkVersion 19
          buildToolsVersion "19.1.0"
      
          defaultConfig {
              applicationId "com.intl.log4j2xtest"
              minSdkVersion 19
              targetSdkVersion 19
              versionCode 1
              versionName "1.0"
          }
          buildTypes {
              release {
                  runProguard false
                  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
              }
          }
          packagingOptions {
              exclude 'META-INF/LICENSE'
              exclude 'META-INF/NOTICE'
          }
      }
      
      dependencies {
          compile fileTree(dir: 'libs', include: ['*.jar'])
          compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0-rc2'
          compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-rc2'
      }
      

        Issue Links

          Activity

          Remko Popma made changes -
          Fix Version/s 2.0.1 [ 12327381 ]
          Hide
          Remko Popma added a comment -

          Sorry, I just made a modification to the fix for LOG4J2-716. Please use the latest trunk.

          Show
          Remko Popma added a comment - Sorry, I just made a modification to the fix for LOG4J2-716 . Please use the latest trunk.
          Hide
          Nelson MELINA added a comment -

          i guess revision 1611007 contain both fixes ?

          I'll test that today.

          Show
          Nelson MELINA added a comment - i guess revision 1611007 contain both fixes ? I'll test that today.
          Hide
          Remko Popma added a comment -

          Nelson, I resolved both LOG4J2-716 (auto-disable JMX) and LOG4J2-719 (NetworkOnMainThreadException).
          Could you verify that the workarounds are no longer necessary, and close both issues?

          Show
          Remko Popma added a comment - Nelson, I resolved both LOG4J2-716 (auto-disable JMX) and LOG4J2-719 (NetworkOnMainThreadException). Could you verify that the workarounds are no longer necessary, and close both issues?
          Remko Popma made changes -
          Link This issue relates to LOG4J2-719 [ LOG4J2-719 ]
          Hide
          Gary Gregory added a comment -

          Yes it is... deleting... good catch, thank you.

          Show
          Gary Gregory added a comment - Yes it is... deleting... good catch, thank you.
          Hide
          Nelson MELINA added a comment -
          Show
          Nelson MELINA added a comment - isn't it the same as https://issues.apache.org/jira/browse/LOG4J2-716 ?
          Hide
          Gary Gregory added a comment -

          I created https://issues.apache.org/jira/browse/LOG4J2-718 to track disabling JMX on Android. Patches welcome.

          Show
          Gary Gregory added a comment - I created https://issues.apache.org/jira/browse/LOG4J2-718 to track disabling JMX on Android. Patches welcome.
          Hide
          Remko Popma added a comment -

          Thanks! Was reaching the same conclusion. So it's just a matter of detecting Android and disabling JMX then.

          Show
          Remko Popma added a comment - Thanks! Was reaching the same conclusion. So it's just a matter of detecting Android and disabling JMX then.
          Hide
          Nelson MELINA added a comment -

          From what i've seen JMX is not supported on Android.

          Show
          Nelson MELINA added a comment - From what i've seen JMX is not supported on Android.
          Hide
          Remko Popma added a comment -

          Nelson, I created LOG4J2-716 to follow up on the JMX issue.

          If you know more about whether JMX is supported or not and perhaps give some sample code for making JMX work on Android that would be much appreciated! In that case please add comments to LOG4J2-716.

          Show
          Remko Popma added a comment - Nelson, I created LOG4J2-716 to follow up on the JMX issue. If you know more about whether JMX is supported or not and perhaps give some sample code for making JMX work on Android that would be much appreciated! In that case please add comments to LOG4J2-716 .
          Remko Popma made changes -
          Link This issue is superceded by LOG4J2-716 [ LOG4J2-716 ]
          Hide
          Gary Gregory added a comment -

          I do not think we have an Android story. We clearly need an Android section in the documentation/site to at least document what we have discovered in this ticket and what levers and knobs need to be set to run on Android. Patches welcome

          Show
          Gary Gregory added a comment - I do not think we have an Android story. We clearly need an Android section in the documentation/site to at least document what we have discovered in this ticket and what levers and knobs need to be set to run on Android. Patches welcome
          Nelson MELINA made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Nelson MELINA added a comment -

          PS: Is it planned to make it "automatically" work on Android (with the accompanying needed documentation) ?

          Show
          Nelson MELINA added a comment - PS: Is it planned to make it "automatically" work on Android (with the accompanying needed documentation) ?
          Hide
          Nelson MELINA added a comment -

          Ok guys, it seems it is working. I still have trouble figuring where to place log4j2.xml so that it is used as a configuration by my main goal of verifying that it could be used in an Android apk is achieved.

          THanks for the help.

          Show
          Nelson MELINA added a comment - Ok guys, it seems it is working. I still have trouble figuring where to place log4j2.xml so that it is used as a configuration by my main goal of verifying that it could be used in an Android apk is achieved. THanks for the help.
          Hide
          Remko Popma added a comment -

          Nelson, you're definitely more advanced than me, since I'm just guessing about anything Android-related...
          Is it possible to call System.setProperty("log4j2.disable.jmx", "true"); at the very beginning of your code, before creating any Loggers?

          Ralph, various people suggest inspecting some system property to detect the Android platform. We can try that.

          Show
          Remko Popma added a comment - Nelson, you're definitely more advanced than me, since I'm just guessing about anything Android-related... Is it possible to call System.setProperty("log4j2.disable.jmx", "true"); at the very beginning of your code, before creating any Loggers? Ralph, various people suggest inspecting some system property to detect the Android platform. We can try that.
          Hide
          Nelson MELINA added a comment -

          Remko Popma I am a little bit of a beginner with Android and it's environment, so i actually don't know where to add this property (i am using Android Studio and Genymotion for the emulator).

          Show
          Nelson MELINA added a comment - Remko Popma I am a little bit of a beginner with Android and it's environment, so i actually don't know where to add this property (i am using Android Studio and Genymotion for the emulator).
          Hide
          Ralph Goers added a comment -

          Is there a way to detect Android and disable JMX automatically? We could also do that for JNDILookup.

          Show
          Ralph Goers added a comment - Is there a way to detect Android and disable JMX automatically? We could also do that for JNDILookup.
          Hide
          Remko Popma added a comment - - edited

          Please set system property -Dlog4j2.disable.jmx=true to work around this issue.

          (This is like whack-a-mole. Fun!)

          Show
          Remko Popma added a comment - - edited Please set system property -Dlog4j2.disable.jmx=true to work around this issue. (This is like whack-a-mole. Fun!)
          Hide
          Nelson MELINA added a comment -

          After modifying the policy and added internet permission to the Android manifest xml file, here is the stacktrace i got.

          07-15 15:12:52.435    1603-1603/com.torointl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-15 15:12:52.435    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve new-instance 396 (Ljavax/naming/InitialContext;) in Lorg/apache/logging/log4j/core/lookup/JndiLookup;
          07-15 15:12:52.439    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve exception class 398 (Ljavax/naming/NamingException;)
          07-15 15:12:52.439    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x19
          07-15 15:12:52.443    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
          07-15 15:12:52.443    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejecting opcode 0x0d at 0x0019
          07-15 15:12:52.443    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
          07-15 15:12:52.443    1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier rejected class Lorg/apache/logging/log4j/core/lookup/JndiLookup;
          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)
          
          Show
          Nelson MELINA added a comment - After modifying the policy and added internet permission to the Android manifest xml file, here is the stacktrace i got. 07-15 15:12:52.435 1603-1603/com.torointl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup 07-15 15:12:52.435 1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve new-instance 396 (Ljavax/naming/InitialContext;) in Lorg/apache/logging/log4j/core/lookup/JndiLookup; 07-15 15:12:52.439 1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve exception class 398 (Ljavax/naming/NamingException;) 07-15 15:12:52.439 1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x19 07-15 15:12:52.443 1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String; 07-15 15:12:52.443 1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejecting opcode 0x0d at 0x0019 07-15 15:12:52.443 1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String; 07-15 15:12:52.443 1603-1603/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier rejected class Lorg/apache/logging/log4j/core/lookup/JndiLookup; 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)
          Hide
          Ralph Goers added a comment - - edited

          I still don't understand why we just don't move the JNDILookup to the web sub-project.

          As for the new error, we are simply trying to setup the hostName property for the configuration to use. It would seem silly to have to spawn a thread just to obtain the hostName. It would be easier to just catch the error and not set the hostName property on Android.

          But I am wondering how may more problems we are going to find before this ticket is closed.

          I suspect this also means you won't be able to use any network based Appenders, since we can't prevent logging from the main thread, unless perhaps Async Loggers work.

          Show
          Ralph Goers added a comment - - edited I still don't understand why we just don't move the JNDILookup to the web sub-project. As for the new error, we are simply trying to setup the hostName property for the configuration to use. It would seem silly to have to spawn a thread just to obtain the hostName. It would be easier to just catch the error and not set the hostName property on Android. But I am wondering how may more problems we are going to find before this ticket is closed. I suspect this also means you won't be able to use any network based Appenders, since we can't prevent logging from the main thread, unless perhaps Async Loggers work.
          Hide
          Nelson MELINA added a comment -

          It looks like "This exception is thrown when an application attempts to perform a networking operation on its main thread."

          http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception

          Show
          Nelson MELINA added a comment - It looks like "This exception is thrown when an application attempts to perform a networking operation on its main thread." http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception
          Hide
          Nelson MELINA added a comment - - edited
          07-15 14:38:37.347    1243-1243/com.torointl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-15 14:38:37.347    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve new-instance 389 (Ljavax/naming/InitialContext;) in Lorg/apache/logging/log4j/core/lookup/JndiLookup;
          07-15 14:38:37.359    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve exception class 391 (Ljavax/naming/NamingException;)
          07-15 14:38:37.359    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x19
          07-15 14:38:37.363    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
          07-15 14:38:37.363    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejecting opcode 0x0d at 0x0019
          07-15 14:38:37.363    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
          07-15 14:38:37.367    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier rejected class Lorg/apache/logging/log4j/core/lookup/JndiLookup;
          07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Landroid/os/NetworkOnMainThreadException; thrown while initializing Lcom/torointl/log4j2xtest/MyActivity;
          07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Class init failed in newInstance call (Lcom/torointl/log4j2xtest/MyActivity;)
          07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d72b20)
          07-15 14:38:37.639    1243-1243/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.torointl.log4j2xtest, PID: 1243
              java.lang.ExceptionInInitializerError
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
               Caused by: android.os.NetworkOnMainThreadException
                      at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
                      at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
                      at java.net.InetAddress.getLocalHost(InetAddress.java:365)
                      at org.apache.logging.log4j.core.util.NetUtils.getLocalHostname(NetUtils.java:47)
                      at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:356)
                      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.<clinit>(MyActivity.java:14)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          
          
          Show
          Nelson MELINA added a comment - - edited 07-15 14:38:37.347 1243-1243/com.torointl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup 07-15 14:38:37.347 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve new-instance 389 (Ljavax/naming/InitialContext;) in Lorg/apache/logging/log4j/core/lookup/JndiLookup; 07-15 14:38:37.359 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve exception class 391 (Ljavax/naming/NamingException;) 07-15 14:38:37.359 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x19 07-15 14:38:37.363 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String; 07-15 14:38:37.363 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejecting opcode 0x0d at 0x0019 07-15 14:38:37.363 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String; 07-15 14:38:37.367 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier rejected class Lorg/apache/logging/log4j/core/lookup/JndiLookup; 07-15 14:38:37.627 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Landroid/os/NetworkOnMainThreadException; thrown while initializing Lcom/torointl/log4j2xtest/MyActivity; 07-15 14:38:37.627 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Class init failed in newInstance call (Lcom/torointl/log4j2xtest/MyActivity;) 07-15 14:38:37.627 1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d72b20) 07-15 14:38:37.639 1243-1243/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.torointl.log4j2xtest, PID: 1243 java.lang.ExceptionInInitializerError at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1208) at android.app.Instrumentation.newActivity(Instrumentation.java:1061) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112) 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) Caused by: android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145) at java.net.InetAddress.lookupHostByName(InetAddress.java:385) at java.net.InetAddress.getLocalHost(InetAddress.java:365) at org.apache.logging.log4j.core.util.NetUtils.getLocalHostname(NetUtils.java:47) at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:356) 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.<clinit>(MyActivity.java:14) at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1208) at android.app.Instrumentation.newActivity(Instrumentation.java:1061) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112) 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)
          Hide
          Matt Sicker added a comment -

          I think it would be better in the long run to make a JNDI wrapper to avoid direct references. That way, Context can implement Closeable, too!

          Show
          Matt Sicker added a comment - I think it would be better in the long run to make a JNDI wrapper to avoid direct references. That way, Context can implement Closeable, too!
          Hide
          Gary Gregory added a comment -

          Please try again with revision 1610654.

          This time, the interpolator class tries to load the JNDI look up class by name, and if it fails, logs a message and the exception. Configuration and processing should continue normally from there on.

          Resolve this issue if this fixes your problem.

          Thank you,
          Gary

          Show
          Gary Gregory added a comment - Please try again with revision 1610654. This time, the interpolator class tries to load the JNDI look up class by name, and if it fails, logs a message and the exception. Configuration and processing should continue normally from there on. Resolve this issue if this fixes your problem. Thank you, Gary
          Gary Gregory made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Hide
          Gary Gregory added a comment -

          I created LOG4J2-713 to deal with the latest issue: java.lang.VerifyError: org/apache/logging/log4j/core/util/Closer because this issue is done and will be in 2.0.

          For java.lang.VerifyError: org/apache/logging/log4j/core/util/Closer, this fix might not be in 2.0, we do not know if the current 2.0 vote will pass.

          Please follow up here: LOG4J2-713

          Show
          Gary Gregory added a comment - I created LOG4J2-713 to deal with the latest issue: java.lang.VerifyError: org/apache/logging/log4j/core/util/Closer because this issue is done and will be in 2.0. For java.lang.VerifyError: org/apache/logging/log4j/core/util/Closer , this fix might not be in 2.0, we do not know if the current 2.0 vote will pass. Please follow up here: LOG4J2-713
          Gary Gregory made changes -
          Link This issue is a clone of LOG4J2-713 [ LOG4J2-713 ]
          Gary Gregory made changes -
          Link This issue is a clone of LOG4J2-712 [ LOG4J2-712 ]
          Gary Gregory made changes -
          Attachment LOG4J2-703-gg.diff [ 12655679 ]
          Hide
          Gary Gregory added a comment -

          The Closer class imports javax classes:

          import javax.naming.Context;
          import javax.naming.NamingException;
          

          A solution would be to split the Closer class into two classes Closer and JndiCloser.

          Show
          Gary Gregory added a comment - The Closer class imports javax classes: import javax.naming.Context; import javax.naming.NamingException; A solution would be to split the Closer class into two classes Closer and JndiCloser .
          Hide
          Nelson MELINA added a comment -

          Still had this error :

          07-14 17:02:49.703    1418-1418/com.torointl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-14 17:02:49.703    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve new-instance 388 (Ljavax/naming/InitialContext;) in Lorg/apache/logging/log4j/core/lookup/JndiLookup;
          07-14 17:02:49.707    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve exception class 390 (Ljavax/naming/NamingException;)
          07-14 17:02:49.707    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x19
          07-14 17:02:49.707    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
          07-14 17:02:49.711    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejecting opcode 0x0d at 0x0019
          07-14 17:02:49.711    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
          07-14 17:02:49.711    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier rejected class Lorg/apache/logging/log4j/core/lookup/JndiLookup;
          07-14 17:02:49.711    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Ljava/lang/VerifyError; thrown while initializing Lorg/apache/logging/log4j/core/LoggerContext;
          07-14 17:02:49.711    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Ljava/lang/VerifyError; thrown while initializing Lcom/torointl/log4j2xtest/MyActivity;
          07-14 17:02:49.715    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ Class init failed in newInstance call (Lcom/torointl/log4j2xtest/MyActivity;)
          07-14 17:02:49.719    1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d16b20)
          07-14 17:02:49.747    1418-1418/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.torointl.log4j2xtest, PID: 1418
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:76)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      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.<clinit>(MyActivity.java:14)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          

          Then i tried by commenting directly this line

           lookups.put("jndi", new JndiLookup()); 

          and got :

          07-14 16:51:59.915    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/naming/Context;)
          07-14 16:51:59.919    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve interface method 920: Ljavax/naming/Context;.close ()V
          07-14 16:51:59.919    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/naming/Context;)
          07-14 16:51:59.919    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/naming/Context;)
          07-14 16:51:59.919    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve exception class 390 (Ljavax/naming/NamingException;)
          07-14 16:51:59.919    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x4
          07-14 16:51:59.923    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejected Lorg/apache/logging/log4j/core/util/Closer;.closeSilently (Ljavax/naming/Context;)V
          07-14 16:51:59.923    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejecting opcode 0x0d at 0x0004
          07-14 16:51:59.923    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:  rejected Lorg/apache/logging/log4j/core/util/Closer;.closeSilently (Ljavax/naming/Context;)V
          07-14 16:51:59.923    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier rejected class Lorg/apache/logging/log4j/core/util/Closer;
          07-14 16:51:59.923    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Ljava/lang/VerifyError; thrown while initializing Lcom/torointl/log4j2xtest/MyActivity;
          07-14 16:51:59.923    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ Class init failed in newInstance call (Lcom/torointl/log4j2xtest/MyActivity;)
          07-14 16:51:59.927    1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d16b20)
          07-14 16:51:59.927    1321-1321/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.torointl.log4j2xtest, PID: 1321
              java.lang.VerifyError: org/apache/logging/log4j/core/util/Closer
                      at org.apache.logging.log4j.core.config.plugins.util.PluginManager.decode(PluginManager.java:180)
                      at org.apache.logging.log4j.core.config.plugins.util.PluginManager.loadPlugins(PluginManager.java:122)
                      at org.apache.logging.log4j.core.config.plugins.util.PluginManager.collectPlugins(PluginManager.java:116)
                      at org.apache.logging.log4j.core.config.plugins.util.PluginManager.collectPlugins(PluginManager.java:101)
                      at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:129)
                      at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:110)
                      at org.apache.logging.log4j.core.layout.PatternLayout.createPatternParser(PatternLayout.java:209)
                      at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:123)
                      at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:54)
                      at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:368)
                      at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:56)
                      at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:72)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      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.<clinit>(MyActivity.java:14)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          
          Show
          Nelson MELINA added a comment - Still had this error : 07-14 17:02:49.703 1418-1418/com.torointl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup 07-14 17:02:49.703 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve new-instance 388 (Ljavax/naming/InitialContext;) in Lorg/apache/logging/log4j/core/lookup/JndiLookup; 07-14 17:02:49.707 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve exception class 390 (Ljavax/naming/NamingException;) 07-14 17:02:49.707 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x19 07-14 17:02:49.707 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String; 07-14 17:02:49.711 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejecting opcode 0x0d at 0x0019 07-14 17:02:49.711 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup (Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String; 07-14 17:02:49.711 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier rejected class Lorg/apache/logging/log4j/core/lookup/JndiLookup; 07-14 17:02:49.711 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Ljava/lang/VerifyError; thrown while initializing Lorg/apache/logging/log4j/core/LoggerContext; 07-14 17:02:49.711 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Ljava/lang/VerifyError; thrown while initializing Lcom/torointl/log4j2xtest/MyActivity; 07-14 17:02:49.715 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ Class init failed in newInstance call (Lcom/torointl/log4j2xtest/MyActivity;) 07-14 17:02:49.719 1418-1418/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d16b20) 07-14 17:02:49.747 1418-1418/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.torointl.log4j2xtest, PID: 1418 java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:76) at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99) at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29) at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72) 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.<clinit>(MyActivity.java:14) at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1208) at android.app.Instrumentation.newActivity(Instrumentation.java:1061) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112) 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) Then i tried by commenting directly this line lookups.put("jndi", new JndiLookup()); and got : 07-14 16:51:59.915 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/naming/Context;) 07-14 16:51:59.919 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve interface method 920: Ljavax/naming/Context;.close ()V 07-14 16:51:59.919 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/naming/Context;) 07-14 16:51:59.919 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljavax/naming/Context;) 07-14 16:51:59.919 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to resolve exception class 390 (Ljavax/naming/NamingException;) 07-14 16:51:59.919 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x4 07-14 16:51:59.923 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejected Lorg/apache/logging/log4j/core/util/Closer;.closeSilently (Ljavax/naming/Context;)V 07-14 16:51:59.923 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejecting opcode 0x0d at 0x0004 07-14 16:51:59.923 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ VFY: rejected Lorg/apache/logging/log4j/core/util/Closer;.closeSilently (Ljavax/naming/Context;)V 07-14 16:51:59.923 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier rejected class Lorg/apache/logging/log4j/core/util/Closer; 07-14 16:51:59.923 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Ljava/lang/VerifyError; thrown while initializing Lcom/torointl/log4j2xtest/MyActivity; 07-14 16:51:59.923 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ Class init failed in newInstance call (Lcom/torointl/log4j2xtest/MyActivity;) 07-14 16:51:59.927 1321-1321/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d16b20) 07-14 16:51:59.927 1321-1321/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.torointl.log4j2xtest, PID: 1321 java.lang.VerifyError: org/apache/logging/log4j/core/util/Closer at org.apache.logging.log4j.core.config.plugins.util.PluginManager.decode(PluginManager.java:180) at org.apache.logging.log4j.core.config.plugins.util.PluginManager.loadPlugins(PluginManager.java:122) at org.apache.logging.log4j.core.config.plugins.util.PluginManager.collectPlugins(PluginManager.java:116) at org.apache.logging.log4j.core.config.plugins.util.PluginManager.collectPlugins(PluginManager.java:101) at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:129) at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:110) at org.apache.logging.log4j.core.layout.PatternLayout.createPatternParser(PatternLayout.java:209) at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:123) at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:54) at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:368) at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:56) at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:72) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72) 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.<clinit>(MyActivity.java:14) at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1208) at android.app.Instrumentation.newActivity(Instrumentation.java:1061) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112) 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)
          Show
          Andreas Opitz added a comment - - edited Nelson MELINA look at this page http://logging.apache.org/log4j/2.x/build.html and http://logging.apache.org/log4j/2.x/source-repository.html .
          Hide
          Nelson MELINA added a comment - - edited

          Gary Gregory Where can i download the code from that revision to use it ?

          Show
          Nelson MELINA added a comment - - edited Gary Gregory Where can i download the code from that revision to use it ?
          Gary Gregory made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.0 [ 12324757 ]
          Resolution Fixed [ 1 ]
          Hide
          Gary Gregory added a comment - - edited

          Committed revision 1609378.

          The code now guards against this failure, logs a warning and continues on its merry way. You just will not be able to do JNDI lookups if JNDI is not there, like apparently, on Android.

          Please test and close if it works for you.

          Show
          Gary Gregory added a comment - - edited Committed revision 1609378. The code now guards against this failure, logs a warning and continues on its merry way. You just will not be able to do JNDI lookups if JNDI is not there, like apparently, on Android. Please test and close if it works for you.
          Gary Gregory made changes -
          Summary Log4J 2 on Android : Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup Android: Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          Hide
          Matt Sicker added a comment -

          Due to the runtime error of constructing JndiLookup, here's something a bit more fault tolerant:

                  if (Loader.isClassAvailable("javax.naming.Context")) {
                      try {
                          lookups.put("jndi", new JndiLookup());
                      } catch (final Throwable ignored) {
                          LOGGER.info("Log4j is running in a JVM that lacks JNDI. JNDI string lookups will not be available.");
                      }
                  }
          

          I was considering loading the JndiLookup class reflectively, too, but it's not a link-time error. The error happens when the constructor is called apparently. Either way, you need to catch Throwable since VerifyError is not an Exception.

          Show
          Matt Sicker added a comment - Due to the runtime error of constructing JndiLookup, here's something a bit more fault tolerant: if (Loader.isClassAvailable( "javax.naming.Context" )) { try { lookups.put( "jndi" , new JndiLookup()); } catch ( final Throwable ignored) { LOGGER.info( "Log4j is running in a JVM that lacks JNDI. JNDI string lookups will not be available." ); } } I was considering loading the JndiLookup class reflectively, too, but it's not a link-time error. The error happens when the constructor is called apparently. Either way, you need to catch Throwable since VerifyError is not an Exception.
          Hide
          Matt Sicker added a comment -

          It's a VerifyError which means it happened at class load time. Needs a layer of indirection to prevent the issue. Probably use reflection, too, to try loading the JNDI classes in that layer as well to prevent class load errors.

          Show
          Matt Sicker added a comment - It's a VerifyError which means it happened at class load time. Needs a layer of indirection to prevent the issue. Probably use reflection, too, to try loading the JNDI classes in that layer as well to prevent class load errors.
          Hide
          Gary Gregory added a comment - - edited

          Why not simply:

          ### Eclipse Workspace Patch 1.0
          #P log4j-core
          Index: src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
          ===================================================================
          --- src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java	(revision 1608975)
          +++ src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java	(working copy)
          @@ -72,7 +72,12 @@
                   // TODO: this ought to use the PluginManager
                   lookups.put("sys", new SystemPropertiesLookup());
                   lookups.put("env", new EnvironmentLookup());
          -        lookups.put("jndi", new JndiLookup());
          +        try {
          +            lookups.put("jndi", new JndiLookup());
          +        } catch (Exception e) {
          +            // We must be on Android
          +            LOGGER.warn("JNDI lookup is not available, continuing configuration without it", e);
          +        }
                   lookups.put("date", new DateLookup());
                   lookups.put("ctx", new ContextMapLookup());
                   if (Loader.isClassAvailable("javax.servlet.ServletContext")) {
          
          Show
          Gary Gregory added a comment - - edited Why not simply: ### Eclipse Workspace Patch 1.0 #P log4j-core Index: src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java =================================================================== --- src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java (revision 1608975) +++ src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java (working copy) @@ -72,7 +72,12 @@ // TODO: this ought to use the PluginManager lookups.put("sys", new SystemPropertiesLookup()); lookups.put("env", new EnvironmentLookup()); - lookups.put("jndi", new JndiLookup()); + try { + lookups.put("jndi", new JndiLookup()); + } catch (Exception e) { + // We must be on Android + LOGGER.warn("JNDI lookup is not available, continuing configuration without it", e); + } lookups.put("date", new DateLookup()); lookups.put("ctx", new ContextMapLookup()); if (Loader.isClassAvailable("javax.servlet.ServletContext")) {
          Hide
          Matt Sicker added a comment -

          It's worth a shot. That's the same resource I found. There may be a process for allowing endorsed JARs for using the javax namespace. If that doesn't work, we may need to figure out a workaround. It may be possible that you'll need to package-rename the JNDI classes (not sure on which ones), and in that case, there would need to be added support for accessing JNDI through a layer of indirection.

          Show
          Matt Sicker added a comment - It's worth a shot. That's the same resource I found. There may be a process for allowing endorsed JARs for using the javax namespace. If that doesn't work, we may need to figure out a workaround. It may be possible that you'll need to package-rename the JNDI classes (not sure on which ones), and in that case, there would need to be added support for accessing JNDI through a layer of indirection.
          Hide
          Nelson MELINA added a comment - - edited

          Yes Matt Sicker it looks like that.

          Should i just copy the javax.naming package in my application like this https://code.google.com/p/dalvik/wiki/JavaxPackages ?

          Show
          Nelson MELINA added a comment - - edited Yes Matt Sicker it looks like that. Should i just copy the javax.naming package in my application like this https://code.google.com/p/dalvik/wiki/JavaxPackages ?
          Hide
          Ralph Goers added a comment -

          To my knowledge no one has ever tested on Android. That said, JndiLookup should probably be in the web sub-project.

          Show
          Ralph Goers added a comment - To my knowledge no one has ever tested on Android. That said, JndiLookup should probably be in the web sub-project.
          Hide
          Matt Sicker added a comment -

          It appears that Android does not ship with the javax.naming package.

          Show
          Matt Sicker added a comment - It appears that Android does not ship with the javax.naming package.
          Nelson MELINA made changes -
          Summary Log4J2 on Android : Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup Log4J 2 on Android : Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          Nelson MELINA made changes -
          Description Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          {noformat}

          build.gradle file :
          {noformat}
          apply plugin: 'com.android.application'

          android {
              compileSdkVersion 19
              buildToolsVersion "19.1.0"

              defaultConfig {
                  applicationId "com.torointl.log4j2xtest"
                  minSdkVersion 19
                  targetSdkVersion 19
                  versionCode 1
                  versionName "1.0"
              }
              buildTypes {
                  release {
                      runProguard false
                      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                  }
              }
              packagingOptions {
                  exclude 'META-INF/LICENSE'
                  exclude 'META-INF/NOTICE'
              }
          }

          dependencies {
              compile fileTree(dir: 'libs', include: ['*.jar'])
              compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0-rc2'
              compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-rc2'
          }
          {noformat}
          Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          {noformat}

          build.gradle file :
          {noformat}
          apply plugin: 'com.android.application'

          android {
              compileSdkVersion 19
              buildToolsVersion "19.1.0"

              defaultConfig {
                  applicationId "com.intl.log4j2xtest"
                  minSdkVersion 19
                  targetSdkVersion 19
                  versionCode 1
                  versionName "1.0"
              }
              buildTypes {
                  release {
                      runProguard false
                      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                  }
              }
              packagingOptions {
                  exclude 'META-INF/LICENSE'
                  exclude 'META-INF/NOTICE'
              }
          }

          dependencies {
              compile fileTree(dir: 'libs', include: ['*.jar'])
              compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0-rc2'
              compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-rc2'
          }
          {noformat}
          Nelson MELINA made changes -
          Description Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          {noformat}
          Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          {noformat}

          build.gradle file :
          {noformat}
          apply plugin: 'com.android.application'

          android {
              compileSdkVersion 19
              buildToolsVersion "19.1.0"

              defaultConfig {
                  applicationId "com.torointl.log4j2xtest"
                  minSdkVersion 19
                  targetSdkVersion 19
                  versionCode 1
                  versionName "1.0"
              }
              buildTypes {
                  release {
                      runProguard false
                      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                  }
              }
              packagingOptions {
                  exclude 'META-INF/LICENSE'
                  exclude 'META-INF/NOTICE'
              }
          }

          dependencies {
              compile fileTree(dir: 'libs', include: ['*.jar'])
              compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0-rc2'
              compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-rc2'
          }
          {noformat}
          Nelson MELINA made changes -
          Description Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity .java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          {noformat}
          Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          {noformat}
          Nelson MELINA made changes -
          Field Original Value New Value
          Description Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity .java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      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.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          {noformat}
          Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity .java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      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)
          {noformat}
          Nelson MELINA created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              Nelson MELINA
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development