Log4j 2
  1. Log4j 2
  2. LOG4J2-587

log4j-1.2-api emulation jar missing classes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-rc1
    • Fix Version/s: None
    • Component/s: log4j 1.2 emulation
    • Labels:

      Description

      The log4j 1.2 emulation jar does not contain AppenderSkeleton. There are several Spring components like spring-amqp that define custom appenders.

      Even if you don't reference those appenders because of various class loading discovery (such as Springs annotation configuration) you will get exceptions like

      java.lang.NoClassDefFoundError: org/apache/log4j/AppenderSkeleton
      	at java.lang.Class.getDeclaredMethods0(Native Method)
      	at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
      	at java.lang.Class.getDeclaredMethods(Class.java:1855)
      	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(
      

      And thus you cannot remove the original log4j-1.2.x jars.

      Basically the class just needs to exist to avoid reflection exceptions like the one above. Unfortunately this is a show stopper for us as we use Spring heavily and and it appears to happen on any of our spring applications and we don't allow jars with duplicate classes in our projets.

      This appears to be an easy fix... just stub all of the log4j-1.2 classes that are extendable.

      The log4j SLF4J bridge does in fact contain the appender skeleton: http://www.slf4j.org/api/org/apache/log4j/package-summary.html

      Consequently a not so ideal workaround is to just use log4j-over-slf4j.jar which does contain the AppenderSkeleton.

        Activity

        Hide
        Gary Gregory added a comment -

        Would you be willing to submit a patch (diff file) with all of the changes you need to get your application up and running?

        Show
        Gary Gregory added a comment - Would you be willing to submit a patch (diff file) with all of the changes you need to get your application up and running?
        Hide
        Adam Gent added a comment -

        Apparently a custom component of ours was accessing AppenderSkeleton (an import statement).

        Show
        Adam Gent added a comment - Apparently a custom component of ours was accessing AppenderSkeleton (an import statement).
        Hide
        Jonathan Bayle added a comment -

        Hello,

        I see that this issue is closed, what is the solution/workaround for it?
        I'd like to use log4j 2.6 in my project but I'm encountering this issue: I have log4j-1.2-api-2.6.2.jar in my classpath and AppenderSkeleton is still missing.
        One dependency extends that class: https://github.com/JumpMind/symmetric-ds/search?q=AppenderSkeleton and if I keep log4j-1.2 in my classpath, loglines printed by that dependency are not correctly formatted.

        Thanks for your help.

        Show
        Jonathan Bayle added a comment - Hello, I see that this issue is closed, what is the solution/workaround for it? I'd like to use log4j 2.6 in my project but I'm encountering this issue: I have log4j-1.2-api-2.6.2.jar in my classpath and AppenderSkeleton is still missing. One dependency extends that class: https://github.com/JumpMind/symmetric-ds/search?q=AppenderSkeleton and if I keep log4j-1.2 in my classpath, loglines printed by that dependency are not correctly formatted. Thanks for your help.
        Hide
        Ralph Goers added a comment -

        Can you provide the stack trace for the error you get? The classes referenced by your link look like "normal" log4j 1.2 appenders and so should not even be referenced if log4j 2 is being used.

        Show
        Ralph Goers added a comment - Can you provide the stack trace for the error you get? The classes referenced by your link look like "normal" log4j 1.2 appenders and so should not even be referenced if log4j 2 is being used.
        Hide
        Jonathan Bayle added a comment -

        Stack trace:

        [1.0-SNAPSHOT][2017-01-19 10:34:08,968][ERROR] Exception in thread "symmetric-engine-startup-0" java.lang.NoClassDefFoundError: org/apache/log4j/AppenderSkeleton (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] 	at java.lang.ClassLoader.defineClass1(Native Method) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] 	at java.lang.ClassLoader.defineClass(ClassLoader.java:763) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] 	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] 	at java.net.URLClassLoader.access$100(URLClassLoader.java:73) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] 	at java.net.URLClassLoader$1.run(URLClassLoader.java:368) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] 	at java.net.URLClassLoader$1.run(URLClassLoader.java:362) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] 	at java.security.AccessController.doPrivileged(Native Method) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] 	at java.net.URLClassLoader.findClass(URLClassLoader.java:361) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] 	at org.jumpmind.symmetric.util.LogSummaryAppenderUtils.registerLogSummaryAppender(LogSummaryAppenderUtils.java:40) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] 	at org.jumpmind.symmetric.ClientSymmetricEngine.init(ClientSymmetricEngine.java:170) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] 	at org.jumpmind.symmetric.web.ServerSymmetricEngine.init(ServerSymmetricEngine.java:62) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] 	at org.jumpmind.symmetric.ClientSymmetricEngine.<init>(ClientSymmetricEngine.java:139) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] 	at org.jumpmind.symmetric.web.ServerSymmetricEngine.<init>(ServerSymmetricEngine.java:47) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] 	at org.jumpmind.symmetric.web.SymmetricEngineHolder.create(SymmetricEngineHolder.java:241) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] 	at org.jumpmind.symmetric.web.SymmetricEngineHolder$EngineStarter.run(SymmetricEngineHolder.java:461) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] Caused by: java.lang.ClassNotFoundException: org.apache.log4j.AppenderSkeleton (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] 	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,972][ERROR] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,972][ERROR] 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,972][ERROR] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        [1.0-SNAPSHOT][2017-01-19 10:34:08,972][ERROR] 	... 19 more (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        
        Show
        Jonathan Bayle added a comment - Stack trace: [1.0-SNAPSHOT][2017-01-19 10:34:08,968][ERROR] Exception in thread "symmetric-engine-startup-0" java.lang.NoClassDefFoundError: org/apache/log4j/AppenderSkeleton (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] at java.lang.ClassLoader.defineClass1(Native Method) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] at java.lang.ClassLoader.defineClass(ClassLoader.java:763) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,969][ERROR] at java.net.URLClassLoader.access$100(URLClassLoader.java:73) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:368) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:362) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] at java.security.AccessController.doPrivileged(Native Method) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:361) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,970][ERROR] at org.jumpmind.symmetric.util.LogSummaryAppenderUtils.registerLogSummaryAppender(LogSummaryAppenderUtils.java:40) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] at org.jumpmind.symmetric.ClientSymmetricEngine.init(ClientSymmetricEngine.java:170) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] at org.jumpmind.symmetric.web.ServerSymmetricEngine.init(ServerSymmetricEngine.java:62) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] at org.jumpmind.symmetric.ClientSymmetricEngine.<init>(ClientSymmetricEngine.java:139) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] at org.jumpmind.symmetric.web.ServerSymmetricEngine.<init>(ServerSymmetricEngine.java:47) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] at org.jumpmind.symmetric.web.SymmetricEngineHolder.create(SymmetricEngineHolder.java:241) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] at org.jumpmind.symmetric.web.SymmetricEngineHolder$EngineStarter.run(SymmetricEngineHolder.java:461) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] Caused by: java.lang.ClassNotFoundException: org.apache.log4j.AppenderSkeleton (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,971][ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:381) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,972][ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,972][ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,972][ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) (SystemLogHandler.java:267 - symmetric-engine-startup-0) [1.0-SNAPSHOT][2017-01-19 10:34:08,972][ERROR] ... 19 more (SystemLogHandler.java:267 - symmetric-engine-startup-0)
        Hide
        Mikael Ståldal added a comment -

        Looks like this symmetric-ds needs to be updated to use Log4j 2.

        Show
        Mikael Ståldal added a comment - Looks like this symmetric-ds needs to be updated to use Log4j 2.
        Hide
        Jonathan Bayle added a comment -

        My project uses Log4j 2, but it also uses SymmetricDS, what should I do?
        I thought the log4j 1.2 bridge was there to workaround these kinds of issue.

        Show
        Jonathan Bayle added a comment - My project uses Log4j 2, but it also uses SymmetricDS, what should I do? I thought the log4j 1.2 bridge was there to workaround these kinds of issue.
        Hide
        Remko Popma added a comment -

        From the stack trace it seems that in

        org.jumpmind.symmetric.util.LogSummaryAppenderUtils.registerLogSummaryAppender(LogSummaryAppenderUtils.java:40) 
        

        the symmetric product is trying to instantiate a class that inherits from AppenderSkeleton. Since that class is not in the classpath, and the product cannot handle situations when AppenderSkeleton is not in the classpath, you are seeing the above problem.

        Log4j2 and the Log4j 1.2 bridge may not be able to help. Symmetric should update their product to remove the hard coded dependency on the Log4j 1.2 AppenderSkeleton class. I suggest you contact them also with this problem description.

        You can try working around the problem by providing a custom org.apache.log4j.AppenderSkeleton class with all methods stubbed out in your application. If that solves the problem it may be useful to others so we should consider including it into the Log4j 1.2 bridge.

        Show
        Remko Popma added a comment - From the stack trace it seems that in org.jumpmind.symmetric.util.LogSummaryAppenderUtils.registerLogSummaryAppender(LogSummaryAppenderUtils.java:40) the symmetric product is trying to instantiate a class that inherits from AppenderSkeleton. Since that class is not in the classpath, and the product cannot handle situations when AppenderSkeleton is not in the classpath, you are seeing the above problem. Log4j2 and the Log4j 1.2 bridge may not be able to help. Symmetric should update their product to remove the hard coded dependency on the Log4j 1.2 AppenderSkeleton class. I suggest you contact them also with this problem description. You can try working around the problem by providing a custom org.apache.log4j.AppenderSkeleton class with all methods stubbed out in your application. If that solves the problem it may be useful to others so we should consider including it into the Log4j 1.2 bridge.

          People

          • Assignee:
            Unassigned
            Reporter:
            Adam Gent
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development