Log4j 2
  1. Log4j 2
  2. LOG4J2-104

LogManager initialization failed when running from Jdeveloper.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta2
    • Fix Version/s: 2.0-beta3
    • Component/s: Configurators
    • Labels:
      None
    • Environment:

      Environment:
      JDeveloper 11.1.1.6.0
      logj42 (apache-log4j-2.0-beta2-bin)
      Windows 7 64bits

      Description

      This issue was incorrectly opened in bugzilla as https://issues.apache.org/bugzilla/show_bug.cgi?id=54053 by Evgeny.

      Steps to Reproduce:
      //config file presents or not - does not meter.

      Run / Debug simple application:

      import org.apache.logging.log4j.LogManager;
      import org.apache.logging.log4j.Logger;

      public class test_log {
      public test_log()

      { super(); }

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

      public static void main(String[] args)

      { test_log test_log = new test_log(); logger.entry(); logger.debug("test"); logger.error("test Err"); logger.exit(); }

      ...
      }

      Actual Results:
      Failed with error
      java.lang.ExceptionInInitializerError
      at view.test_log.<clinit>(test_log.java:13)
      Caused by: java.lang.ClassCastException: oracle.xml.parser.v2.DTD cannot be cast to org.w3c.dom.Element
      at java.util.XMLUtils.load(XMLUtils.java:61)
      at java.util.Properties.loadFromXML(Properties.java:852)
      at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:77)

      Additional Info:
      When xmlparserv2.jar is deleted - application run fine.
      But - it have to be presents - when deleted, JDeveloper failed to start.

        Activity

        Hide
        Ralph Goers added a comment -

        The reporter of this problem also has asked on Oracle's forum for a solution - https://forums.oracle.com/forums/thread.jspa?messageID=10657822. In addition, I see at least one other similar report - https://forums.oracle.com/forums/thread.jspa?messageID=9341563. A bug was also opened against the JDK - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7099658 - which was closed as being a bug in XMLUtils. It appears Oracle is simply ignoring this bug.

        Show
        Ralph Goers added a comment - The reporter of this problem also has asked on Oracle's forum for a solution - https://forums.oracle.com/forums/thread.jspa?messageID=10657822 . In addition, I see at least one other similar report - https://forums.oracle.com/forums/thread.jspa?messageID=9341563 . A bug was also opened against the JDK - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7099658 - which was closed as being a bug in XMLUtils. It appears Oracle is simply ignoring this bug.
        Hide
        Noel Grandin added a comment -

        Ralph, from my reading of the JDK bug report, Oracle has fixed the bug in various versions of Java.
        They appear to have fixed it in 6u29 and backported the fix to various places.

        Unfortunately I don't see a easy work-around, short of cut and pasting a fair chunk of code from java.util.Properties and java.util.XMLUtils into LogManager.

        Show
        Noel Grandin added a comment - Ralph, from my reading of the JDK bug report, Oracle has fixed the bug in various versions of Java. They appear to have fixed it in 6u29 and backported the fix to various places. Unfortunately I don't see a easy work-around, short of cut and pasting a fair chunk of code from java.util.Properties and java.util.XMLUtils into LogManager.
        Hide
        Evgeny added a comment -

        Ralph, Noel
        Thanks for your quick replay.

        Is it some way to skip LogManager configuration loading? If i'll configure it in the code instead of config file - file it allow me to bypass this issue?

        By the way - if I'll use stable (not beta) release of log4j (1.x) - will it also use same way to load configuration?
        We just need to decide about logging framework for our new project, and this issue is look like blocker for us.

        Thanks!

        Show
        Evgeny added a comment - Ralph, Noel Thanks for your quick replay. Is it some way to skip LogManager configuration loading? If i'll configure it in the code instead of config file - file it allow me to bypass this issue? By the way - if I'll use stable (not beta) release of log4j (1.x) - will it also use same way to load configuration? We just need to decide about logging framework for our new project, and this issue is look like blocker for us. Thanks!
        Hide
        Ralph Goers added a comment -

        I am looking at addressing this in at least two ways.

        1. I'm going to switch from using loadFromXML to load and convert the properties file from XML to a "normal" properties format.
        2. I'm planning on creating a combined jar where the api and core are merged together. There will still be some binding but it will use a (hopefully) simpler method.

        Log4j 1.x does not use this mechanism because there is no separation between the API and implementation.

        Show
        Ralph Goers added a comment - I am looking at addressing this in at least two ways. 1. I'm going to switch from using loadFromXML to load and convert the properties file from XML to a "normal" properties format. 2. I'm planning on creating a combined jar where the api and core are merged together. There will still be some binding but it will use a (hopefully) simpler method. Log4j 1.x does not use this mechanism because there is no separation between the API and implementation.
        Hide
        Ralph Goers added a comment -

        I attempted to verify the problem by running the above program in JDeveloper on both my Mac and Windows 7, but neither experienced the problem. I was running JDeveloper 11.1.2.3.0 on Windows 7 64 bit with JDK 1.6.0_24. This is going to make it difficult for me to verify that the change I'm implementing actually fixes the problem.

        Show
        Ralph Goers added a comment - I attempted to verify the problem by running the above program in JDeveloper on both my Mac and Windows 7, but neither experienced the problem. I was running JDeveloper 11.1.2.3.0 on Windows 7 64 bit with JDK 1.6.0_24. This is going to make it difficult for me to verify that the change I'm implementing actually fixes the problem.
        Hide
        Evgeny added a comment -

        Ralph,
        Do you have xmlparserv2.jar in your classpath? It is the root of my issue.

        Show
        Evgeny added a comment - Ralph, Do you have xmlparserv2.jar in your classpath? It is the root of my issue.
        Hide
        Ralph Goers added a comment -

        I did nothing special. My understanding was that simply trying to test under JDeveloper caused the problem. Your report says removing xmlparserv2 causes JDeveloper not to start. Is there something else I need to do to cause the problem?

        FYI - I created a Maven project with the code above as the only application. I then imported the application, which was a bit frustrating as it didn't seem to accomplish much. I then had to manually add the log4j 2 jars into the classpath along with target/classes and had to make a couple of other changes so that it knew how things were laid out in the project. I then ran the application from JDeveloper and it ran fine.

        Show
        Ralph Goers added a comment - I did nothing special. My understanding was that simply trying to test under JDeveloper caused the problem. Your report says removing xmlparserv2 causes JDeveloper not to start. Is there something else I need to do to cause the problem? FYI - I created a Maven project with the code above as the only application. I then imported the application, which was a bit frustrating as it didn't seem to accomplish much. I then had to manually add the log4j 2 jars into the classpath along with target/classes and had to make a couple of other changes so that it knew how things were laid out in the project. I then ran the application from JDeveloper and it ran fine.
        Hide
        Ralph Goers added a comment -

        I was able to manually add the xmlparserv2 jar to the classpath and duplicate the error. I'm still not sure why this jar is required but I have changed LogManager to use a regular properties file and verified it works even with Oracle's jar present.

        Please verify the fix and close this.

        Show
        Ralph Goers added a comment - I was able to manually add the xmlparserv2 jar to the classpath and duplicate the error. I'm still not sure why this jar is required but I have changed LogManager to use a regular properties file and verified it works even with Oracle's jar present. Please verify the fix and close this.
        Hide
        Evgeny added a comment -

        Ralph,
        Sorry, but I am new in Jira and Bugzilla. Where can I obtain the fixed version (beta-3) - I want verify it on my environment? On the log4j download page it is only beta2 available.

        Thank you!

        Show
        Evgeny added a comment - Ralph, Sorry, but I am new in Jira and Bugzilla. Where can I obtain the fixed version (beta-3) - I want verify it on my environment? On the log4j download page it is only beta2 available. Thank you!
        Hide
        Ralph Goers added a comment -

        beta-3 has not been released yet so right now you can only test against 2.0-beta3-SNAPSHOT. You have to check it out from subversion and build it yourself or I could deploy the artifacts to the Apache snapshot repository but you would need to add that to your list of repositories.

        See http://logging.apache.org/log4j/2.x/source-repository.html for information on how to check out the source. To build just run mvn clean install in the root directory of the checked out project.

        Show
        Ralph Goers added a comment - beta-3 has not been released yet so right now you can only test against 2.0-beta3-SNAPSHOT. You have to check it out from subversion and build it yourself or I could deploy the artifacts to the Apache snapshot repository but you would need to add that to your list of repositories. See http://logging.apache.org/log4j/2.x/source-repository.html for information on how to check out the source. To build just run mvn clean install in the root directory of the checked out project.
        Hide
        Evgeny added a comment -

        If its possible - i'll prefer you to build it and i'll download the artifacts.
        Thank you

        By the way - do you have approximation for the final release of log4j2?

        Show
        Evgeny added a comment - If its possible - i'll prefer you to build it and i'll download the artifacts. Thank you By the way - do you have approximation for the final release of log4j2?
        Hide
        Evgeny added a comment -

        Ralph,
        I think I did not explain myself right - I just switched to java from dot net, so I still not so comfortable with java environment. This is the reason I prefer to download ready build - i want to verify the fix but avoid invalid builds and other issues as well as my svn invalid work errors.

        Thank you!

        Show
        Evgeny added a comment - Ralph, I think I did not explain myself right - I just switched to java from dot net, so I still not so comfortable with java environment. This is the reason I prefer to download ready build - i want to verify the fix but avoid invalid builds and other issues as well as my svn invalid work errors. Thank you!
        Hide
        Evgeny added a comment -

        Ralph, hello
        I several times tried to check out via svn the sources to compile them.
        I was not able to find snapshot 2.0-beta3-SNAPSHOT.

        When are you planing to release next version of log4j2? I cannot use it now in my code, it is blocking me now... I also cannot verify the fix.

        Thank you!

        Show
        Evgeny added a comment - Ralph, hello I several times tried to check out via svn the sources to compile them. I was not able to find snapshot 2.0-beta3-SNAPSHOT. When are you planing to release next version of log4j2? I cannot use it now in my code, it is blocking me now... I also cannot verify the fix. Thank you!
        Hide
        Ralph Goers added a comment -

        I had planned to start the release yesterday but my day job got in the way. I just deployed the snapshots so you can give it a try.

        Show
        Ralph Goers added a comment - I had planned to start the release yesterday but my day job got in the way. I just deployed the snapshots so you can give it a try.
        Hide
        Evgeny added a comment -

        Hi Ralph
        I was out of office, so I was able to test the fix only now.
        It is working as expected.

        Thank you!

        Need I change the status of this issue?

        Show
        Evgeny added a comment - Hi Ralph I was out of office, so I was able to test the fix only now. It is working as expected. Thank you! Need I change the status of this issue?

          People

          • Assignee:
            Ralph Goers
            Reporter:
            Ralph Goers
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development