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

ScriptEngineManager is not available in Android and causes a NoClassDefFoundError

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.8.2
    • Fix Version/s: 2.9.0
    • Component/s: JMX
    • Labels:
      None
    • Environment:

      While using with Android

      Description

      Hi Team,

      I integrated Log4j v2.3 initially and I was getting the following crash in my application.

      05-25 09:49:59.099 E/AndroidRuntime(24561): FATAL EXCEPTION: main
      05-25 09:49:59.099 E/AndroidRuntime(24561): java.lang.NoClassDefFoundError: org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup

      Later on, I was checking the open tickets like https://issues.apache.org/jira/browse/LOG4J2-716 and found the issue to be the version that I am using.

      So, I upgraded to latest 2.8.2 version and made some modifications in the code. I see that the above JMX exception is being "caught" and printed in the console. So now I have bypassed that crash and landed in a new crash. I am pasting the stack trace below. Please have a look and advice.

      05-25 15:12:58.634 E/AndroidRuntime(27649): FATAL EXCEPTION: main
      05-25 15:12:58.634 E/AndroidRuntime(27649): java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/script/ScriptEngineManager;
      05-25 15:12:58.634 E/AndroidRuntime(27649): at org.apache.logging.log4j.core.script.ScriptManager.<init>(ScriptManager.java:68)
      05-25 15:12:58.634 E/AndroidRuntime(27649): at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:214)
      05-25 15:12:58.634 E/AndroidRuntime(27649): at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:244)
      05-25 15:12:58.634 E/AndroidRuntime(27649): at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
      05-25 15:12:58.634 E/AndroidRuntime(27649): at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)

      This exception occurs when I am trying LoggerContext.start(). Please advise way forward.

      -Ajitha Yasmin

        Activity

        Hide
        ralph.goers@dslextreme.com Ralph Goers added a comment - - edited

        This should be easy to deal with - but it will mean Log4j won't have any script support.

        Show
        ralph.goers@dslextreme.com Ralph Goers added a comment - - edited This should be easy to deal with - but it will mean Log4j won't have any script support.
        Hide
        garydgregory Gary Gregory added a comment -

        I am working on a patch which will be trivial. We could allow for JavaScript by using Rhino directly or Apache Commons BSF. We could also create our own scripting API with plugins for JSR 223, direct Rhino and Commons BSF... Bleh. If scripting matters to Android devs, then we can be open to contributions.

        Show
        garydgregory Gary Gregory added a comment - I am working on a patch which will be trivial. We could allow for JavaScript by using Rhino directly or Apache Commons BSF. We could also create our own scripting API with plugins for JSR 223, direct Rhino and Commons BSF... Bleh. If scripting matters to Android devs, then we can be open to contributions.
        Hide
        garydgregory Gary Gregory added a comment -

        I am changing the priority to Blocker since this breaks Log4j completely on Android.

        Show
        garydgregory Gary Gregory added a comment - I am changing the priority to Blocker since this breaks Log4j completely on Android.
        Hide
        garydgregory Gary Gregory added a comment -

        I would be nice to have some way to run some tests on Jenkis within some Android sandbox...

        Show
        garydgregory Gary Gregory added a comment - I would be nice to have some way to run some tests on Jenkis within some Android sandbox...
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 96aeca3827fbf5c0aa4b64d2b2bf7cd887325fea in logging-log4j2's branch refs/heads/master from ggregory
        [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=96aeca3 ]

        LOG4J2-1920ScriptEngineManager is not available in Android and causes
        a NoClassDefFoundError. 'mvn clean install' builds.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 96aeca3827fbf5c0aa4b64d2b2bf7cd887325fea in logging-log4j2's branch refs/heads/master from ggregory [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=96aeca3 ] LOG4J2-1920 ScriptEngineManager is not available in Android and causes a NoClassDefFoundError. 'mvn clean install' builds.
        Hide
        garydgregory Gary Gregory added a comment -

        Fixed in master with commit 96aeca3827fbf5c0aa4b64d2b2bf7cd887325fea

        Show
        garydgregory Gary Gregory added a comment - Fixed in master with commit 96aeca3827fbf5c0aa4b64d2b2bf7cd887325fea
        Hide
        garydgregory Gary Gregory added a comment -

        Please verify and close.

        Show
        garydgregory Gary Gregory added a comment - Please verify and close.
        Hide
        Ajitha Ajitha added a comment -
        Show
        Ajitha Ajitha added a comment - When can I expect this in maven : https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
        Hide
        garydgregory Gary Gregory added a comment - - edited

        That's hard to say. One of our PMC (volunteer) members would have to step up and go through our release procedures. I do not have that many extra cycles myself ATM.

        Show
        garydgregory Gary Gregory added a comment - - edited That's hard to say. One of our PMC (volunteer) members would have to step up and go through our release procedures. I do not have that many extra cycles myself ATM.
        Hide
        ralph.goers@dslextreme.com Ralph Goers added a comment - - edited

        We can deploy a SNAPSHOT for you to test with. It wouldn't be available at mvnrepository though. It would be on the Apache Nexus repository. Also, I don't think we are in a state where we want to perform a release right now.

        Show
        ralph.goers@dslextreme.com Ralph Goers added a comment - - edited We can deploy a SNAPSHOT for you to test with. It wouldn't be available at mvnrepository though. It would be on the Apache Nexus repository. Also, I don't think we are in a state where we want to perform a release right now.
        Hide
        Ajitha Ajitha added a comment -

        Thats great. Please share a link for the snapshot. I would pull it and verify the issue.

        Show
        Ajitha Ajitha added a comment - Thats great. Please share a link for the snapshot. I would pull it and verify the issue.
        Hide
        ralph.goers@dslextreme.com Ralph Goers added a comment -

        I have deployed SNAPSHOTs to repository.apache.org. https://repository.apache.org/content/groups/snapshots/org/apache/logging/log4j/. Just make sure you have the apache snapshots repo configured in your maven build and they should download automatically, The version is 2.8.3-SNAPSHOT.

        Show
        ralph.goers@dslextreme.com Ralph Goers added a comment - I have deployed SNAPSHOTs to repository.apache.org. https://repository.apache.org/content/groups/snapshots/org/apache/logging/log4j/ . Just make sure you have the apache snapshots repo configured in your maven build and they should download automatically, The version is 2.8.3-SNAPSHOT.
        Hide
        Ajitha Ajitha added a comment -

        Thanks for the excellent and prompt support. It worked like a charm. I am able to use log4j in Android now.

        Show
        Ajitha Ajitha added a comment - Thanks for the excellent and prompt support. It worked like a charm. I am able to use log4j in Android now.
        Hide
        mounicakodela Mounica Kodela added a comment -

        Hi Ajitha,

        Did you tried using 2.9.0 in your android application. I am not able to run the application using log4j 2.9.0 to test this issue.

        Show
        mounicakodela Mounica Kodela added a comment - Hi Ajitha , Did you tried using 2.9.0 in your android application. I am not able to run the application using log4j 2.9.0 to test this issue.

          People

          • Assignee:
            garydgregory Gary Gregory
            Reporter:
            Ajitha Ajitha
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development