Log4j 2
  1. Log4j 2
  2. LOG4J2-760

XMLLayout's dependence on jackson-annotations should be documented

    Details

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

      Windows JDK 1.7.0_65

      Description

      Hello--first time report please bear with me.
      Upgrading project from 2.0-rc1 to 2.0, ran into the following issue:
      Layout<? extends Serializable> xmlLayout = xmlLayout.createDefaultLayout();

      produces the following error:
      Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException

      I've included the API and Core JAR's to the project path, as previously. For reference, I'm comparing this line with the following line that runs correctly in rc1:
      Layout<? extends Serializable> fileXMLLayout = XMLLayout.createLayout("true", "true", null, null, null, null);

      1. screenshot - with Jacson 2.4.1.jpg
        214 kB
        Dale Furrow
      2. screenshot-success.jpg
        109 kB
        Dale Furrow
      3. BasicScreenshot.jpg
        159 kB
        Dale Furrow

        Activity

        Hide
        Remko Popma added a comment -

        Fixed in revision 1617306.
        Please verify and close.

        Show
        Remko Popma added a comment - Fixed in revision 1617306. Please verify and close.
        Hide
        Gary Gregory added a comment -

        Good idea.

        Show
        Gary Gregory added a comment - Good idea.
        Hide
        Remko Popma added a comment - - edited

        How about this?

        We already have a manually maintained list of what dependencies log4j functions require, and Maven already generates a Dependency Tree.

        What if we link to the Dependency Tree from the manually maintained list and from the FAQ page?

        Show
        Remko Popma added a comment - - edited How about this? We already have a manually maintained list of what dependencies log4j functions require , and Maven already generates a Dependency Tree . What if we link to the Dependency Tree from the manually maintained list and from the FAQ page?
        Hide
        Remko Popma added a comment -

        mvn dependency:tree gives:

        --- maven-dependency-plugin:2.1:tree (default-cli) @ log4j-core ---
        org.apache.logging.log4j:log4j-core:jar:2.0.2-SNAPSHOT
        +- org.apache.logging.log4j:log4j-api:jar:2.0.2-SNAPSHOT:compile
        +- org.osgi:org.osgi.core:jar:4.3.1:provided
        +- com.lmax:disruptor:jar:3.3.0:compile
        +- com.fasterxml.jackson.core:jackson-core:jar:2.4.1.1:compile
        +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.1.3:compile
        |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.0:compile
        +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.4.1:compile
        +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.4.1:compile
        |  +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.4.1:compile
        |  \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
        +- org.codehaus.woodstox:woodstox-core-asl:jar:4.3.0:compile
        |  \- javax.xml.stream:stax-api:jar:1.0-2:compile
        +- org.fusesource.jansi:jansi:jar:1.11:compile
        +- org.jboss.spec.javax.jms:jboss-jms-api_1.1_spec:jar:1.0.1.Final:provided
        +- com.sun.mail:javax.mail:jar:1.5.0:compile
        |  \- javax.activation:activation:jar:1.1:compile
        +- org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
        
        +- org.apache.logging.log4j:log4j-api:test-jar:tests:2.0.2-SNAPSHOT:test
        +- javax.jmdns:jmdns:jar:3.4.1:test
        +- log4j:log4j:jar:1.2.17:test
        +- org.slf4j:slf4j-api:jar:1.7.7:test
        +- org.slf4j:slf4j-ext:jar:1.7.7:test
        |  \- ch.qos.cal10n:cal10n-api:jar:0.8.1:test
        +- junit:junit:jar:4.11:test
        |  \- org.hamcrest:hamcrest-core:jar:1.3:test
        +- org.hamcrest:hamcrest-all:jar:1.3:test
        +- org.easymock:easymock:jar:3.2:test
        |  +- cglib:cglib-nodep:jar:2.2.2:test
        |  \- org.objenesis:objenesis:jar:1.3:test
        +- org.hsqldb:hsqldb:jar:2.3.2:test
        +- com.h2database:h2:jar:1.3.175:test
        +- org.eclipse.persistence:org.eclipse.persistence.jpa:jar:2.5.1:test
        |  +- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.1:test
        |  +- org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.5.1:test
        |  +- org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:jar:2.5.1:test
        |  \- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.1:test
        +- org.mockejb:mockejb:jar:0.6-beta2:test
        |  +- oro:oro:jar:2.0.8:test
        |  \- cglib:cglib-full:jar:2.0.2:test
        +- commons-logging:commons-logging:jar:1.2:test
        +- ch.qos.logback:logback-core:jar:1.0.13:test
        +- ch.qos.logback:logback-classic:jar:1.0.13:test
        +- org.eclipse.osgi:org.eclipse.osgi:jar:3.6.0.v20100517:test
        +- org.apache.felix:org.apache.felix.framework:jar:4.2.1:test
        

        That may be the extend of what can be done automatically with Maven. It does not tell us what feature these dependencies are used for. That may take some manual work.

        Show
        Remko Popma added a comment - mvn dependency:tree gives: --- maven-dependency-plugin:2.1:tree ( default -cli) @ log4j-core --- org.apache.logging.log4j:log4j-core:jar:2.0.2-SNAPSHOT +- org.apache.logging.log4j:log4j-api:jar:2.0.2-SNAPSHOT:compile +- org.osgi:org.osgi.core:jar:4.3.1:provided +- com.lmax:disruptor:jar:3.3.0:compile +- com.fasterxml.jackson.core:jackson-core:jar:2.4.1.1:compile +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.1.3:compile | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.0:compile +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.4.1:compile +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.4.1:compile | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.4.1:compile | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile +- org.codehaus.woodstox:woodstox-core-asl:jar:4.3.0:compile | \- javax.xml.stream:stax-api:jar:1.0-2:compile +- org.fusesource.jansi:jansi:jar:1.11:compile +- org.jboss.spec.javax.jms:jboss-jms-api_1.1_spec:jar:1.0.1.Final:provided +- com.sun.mail:javax.mail:jar:1.5.0:compile | \- javax.activation:activation:jar:1.1:compile +- org.eclipse.persistence:javax.persistence:jar:2.1.0:compile +- org.apache.logging.log4j:log4j-api:test-jar:tests:2.0.2-SNAPSHOT:test +- javax.jmdns:jmdns:jar:3.4.1:test +- log4j:log4j:jar:1.2.17:test +- org.slf4j:slf4j-api:jar:1.7.7:test +- org.slf4j:slf4j-ext:jar:1.7.7:test | \- ch.qos.cal10n:cal10n-api:jar:0.8.1:test +- junit:junit:jar:4.11:test | \- org.hamcrest:hamcrest-core:jar:1.3:test +- org.hamcrest:hamcrest-all:jar:1.3:test +- org.easymock:easymock:jar:3.2:test | +- cglib:cglib-nodep:jar:2.2.2:test | \- org.objenesis:objenesis:jar:1.3:test +- org.hsqldb:hsqldb:jar:2.3.2:test +- com.h2database:h2:jar:1.3.175:test +- org.eclipse.persistence:org.eclipse.persistence.jpa:jar:2.5.1:test | +- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.1:test | +- org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.5.1:test | +- org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:jar:2.5.1:test | \- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.1:test +- org.mockejb:mockejb:jar:0.6-beta2:test | +- oro:oro:jar:2.0.8:test | \- cglib:cglib-full:jar:2.0.2:test +- commons-logging:commons-logging:jar:1.2:test +- ch.qos.logback:logback-core:jar:1.0.13:test +- ch.qos.logback:logback-classic:jar:1.0.13:test +- org.eclipse.osgi:org.eclipse.osgi:jar:3.6.0.v20100517:test +- org.apache.felix:org.apache.felix.framework:jar:4.2.1:test That may be the extend of what can be done automatically with Maven. It does not tell us what feature these dependencies are used for. That may take some manual work.
        Hide
        Ralph Goers added a comment -

        I would like to see a table for core that lists all the optional dependencies and what features they are required for.

        Show
        Ralph Goers added a comment - I would like to see a table for core that lists all the optional dependencies and what features they are required for.
        Hide
        Remko Popma added a comment -

        Okay, so you don't want to do option 1. Fair enough, no problem.

        Just to be clear, I don't think that option 3 (not doing anything) is good either.

        If I understand you correctly you are saying there is a fourth option which is to generate more detailed dependency documentation based on our current POM. I'm fine with that too. (However, if we cannot get that to work then I would just add a few lines to the site.)

        Show
        Remko Popma added a comment - Okay, so you don't want to do option 1. Fair enough, no problem. Just to be clear, I don't think that option 3 (not doing anything) is good either. If I understand you correctly you are saying there is a fourth option which is to generate more detailed dependency documentation based on our current POM. I'm fine with that too. (However, if we cannot get that to work then I would just add a few lines to the site.)
        Hide
        Gary Gregory added a comment -

        I am against changing the POM to deal with this issue. This is only a documentation issue for users that do not use a dependency management build tool, be it Maven, Ivy, or something else. Editing the POM opens the door to editing all POMs to list all transitive dependencies, which defeats one of the purposes behind using Maven in the first place.

        I do not think this is a problem that needs solving beyond automatically generating docs based on the POM. Maven already generates reports for this kind of dependencies. What we are dealing with here is a finer grain level of documentation since not all deps are required to use the core jar.

        Show
        Gary Gregory added a comment - I am against changing the POM to deal with this issue. This is only a documentation issue for users that do not use a dependency management build tool, be it Maven, Ivy, or something else. Editing the POM opens the door to editing all POMs to list all transitive dependencies, which defeats one of the purposes behind using Maven in the first place. I do not think this is a problem that needs solving beyond automatically generating docs based on the POM. Maven already generates reports for this kind of dependencies. What we are dealing with here is a finer grain level of documentation since not all deps are required to use the core jar.
        Hide
        Remko Popma added a comment - - edited

        Bear in mind that if users are using Maven this problem will not occur (Maven will pull in the transitive dependencies). If users can execute Maven commands they likely won't have this issue.

        I see these three options (there may be others, let me know if you think of any)

        1. Add an explicit dependency to jackson-annotations in log4j-core/pom.xml.
          • Pros: only one place to maintain, docs generated automatically.
          • Cons: not strictly necessary for the build and if Jackson changes in the future we need to manually update.
        2. Document the dependency on the site (Layout manual pages and perhaps the FAQ page).
          • Pros: ?. (Perhaps this is user-friendlier?)
          • Cons: multiple places to edit, if Jackson changes in the future we still need to manually update.
        3. Leave it as it is (leave this issue unsolved).
          • Pros: nothing to edit now, no updates required if Jackson changes in the future.
          • Cons: Users without an automatic build system will have trouble using XML and JSON layouts.

        Sounds like updating the core pom is the least work (least of all evils?), but I'd be okay with updating the site docs too...

        Show
        Remko Popma added a comment - - edited Bear in mind that if users are using Maven this problem will not occur (Maven will pull in the transitive dependencies). If users can execute Maven commands they likely won't have this issue. I see these three options (there may be others, let me know if you think of any) Add an explicit dependency to jackson-annotations in log4j-core/pom.xml. Pros: only one place to maintain, docs generated automatically. Cons: not strictly necessary for the build and if Jackson changes in the future we need to manually update. Document the dependency on the site (Layout manual pages and perhaps the FAQ page). Pros: ?. (Perhaps this is user-friendlier?) Cons: multiple places to edit, if Jackson changes in the future we still need to manually update. Leave it as it is (leave this issue unsolved). Pros: nothing to edit now, no updates required if Jackson changes in the future. Cons: Users without an automatic build system will have trouble using XML and JSON layouts. Sounds like updating the core pom is the least work (least of all evils?), but I'd be okay with updating the site docs too...
        Hide
        Matt Sicker added a comment -

        The core and api jars are indeed standalone. However, log4j-core references several optional features as well that require dependencies. The XML and JSON layouts are one of those optional features that are handy for networked logging. Due to the nature of all the standard Java XML APIs, there was no real good way to handle this without introducing a dependency or reinventing the wheel with yet another XML library.

        Show
        Matt Sicker added a comment - The core and api jars are indeed standalone. However, log4j-core references several optional features as well that require dependencies. The XML and JSON layouts are one of those optional features that are handy for networked logging. Due to the nature of all the standard Java XML APIs, there was no real good way to handle this without introducing a dependency or reinventing the wheel with yet another XML library.
        Hide
        Dale Furrow added a comment -

        If I can chime in here-I'd be fine if this section http://logging.apache.org/log4j/2.x/faq.html#which_jars were amended to make it clear that particular functions of core require jars from POM. The project where I used rc-1 was working with the api and core jars only, as that documentation indicated. Now, that's no longer the case. If you just noted that the full functionality of the core jar requires all the dependent jars from the POM (including transitives), and then maybe a link-that would have been good enough for me. Right now, at least to me, the documentation implies those jars are stand-alone.

        Show
        Dale Furrow added a comment - If I can chime in here-I'd be fine if this section http://logging.apache.org/log4j/2.x/faq.html#which_jars were amended to make it clear that particular functions of core require jars from POM. The project where I used rc-1 was working with the api and core jars only, as that documentation indicated. Now, that's no longer the case. If you just noted that the full functionality of the core jar requires all the dependent jars from the POM (including transitives), and then maybe a link-that would have been good enough for me. Right now, at least to me, the documentation implies those jars are stand-alone.
        Hide
        Gary Gregory added a comment -

        Is there no way to generate this automatically from the POM? Is the Maven dependency report not good enough? I wonder how far we need to go and document this kind of stuff. It seems that one alternative would be to point users to Maven commands to print these deps out to the console.

        Show
        Gary Gregory added a comment - Is there no way to generate this automatically from the POM? Is the Maven dependency report not good enough? I wonder how far we need to go and document this kind of stuff. It seems that one alternative would be to point users to Maven commands to print these deps out to the console.
        Hide
        Remko Popma added a comment -

        Okay, shall we just document it on the site then?

        Show
        Remko Popma added a comment - Okay, shall we just document it on the site then?
        Hide
        Gary Gregory added a comment -

        Should we just add an explicit dependency to jackson-annotations in log4j-core/pom.xml?

        I do not think so. If jackson-annotations gets dragged in transitively now, it does not mean it will in the future. That's what transitive closure is for!

        Show
        Gary Gregory added a comment - Should we just add an explicit dependency to jackson-annotations in log4j-core/pom.xml? I do not think so. If jackson-annotations gets dragged in transitively now, it does not mean it will in the future. That's what transitive closure is for!
        Hide
        Remko Popma added a comment -

        Should we just add an explicit dependency to jackson-annotations in log4j-core/pom.xml?

        Show
        Remko Popma added a comment - Should we just add an explicit dependency to jackson-annotations in log4j-core/pom.xml?
        Hide
        Remko Popma added a comment -

        Changed summary (was: XMLLayout NoClassDefFoundError)

        Show
        Remko Popma added a comment - Changed summary (was: XMLLayout NoClassDefFoundError)
        Hide
        Remko Popma added a comment -

        Glad to hear that, Dale!

        Perhaps the XML, JSON and YAML Layout docs should explicitly mention the jackson-annotations jar? Without Maven/Ivy users will not be able to find out what's wrong...
        Gary, what do you think?

        Show
        Remko Popma added a comment - Glad to hear that, Dale! Perhaps the XML, JSON and YAML Layout docs should explicitly mention the jackson-annotations jar? Without Maven/Ivy users will not be able to find out what's wrong... Gary, what do you think?
        Hide
        Dale Furrow added a comment -

        Thanks All--that worked; Remko that last jar was indeed the problem.
        That resolves the issue for me, but I see there is discussion about why this jar isn't on the dependency list.
        If I need to formally close the issue out, please let me know.
        I appreciate the prompt response and helpful suggestions.

        Show
        Dale Furrow added a comment - Thanks All--that worked; Remko that last jar was indeed the problem. That resolves the issue for me, but I see there is discussion about why this jar isn't on the dependency list. If I need to formally close the issue out, please let me know. I appreciate the prompt response and helpful suggestions.
        Hide
        Gary Gregory added a comment -

        I do not see mention of a "jackson-annotations" artifact ID in pom.xml files in trunk but it is brought in transitively. Maybe the maven plugin has a switch for that?

        Show
        Gary Gregory added a comment - I do not see mention of a "jackson-annotations" artifact ID in pom.xml files in trunk but it is brought in transitively. Maybe the maven plugin has a switch for that?
        Hide
        Remko Popma added a comment -

        Gary, any idea why this jar is picked up during the log4j build, but not mentioned in our dependencies page?

        Show
        Remko Popma added a comment - Gary, any idea why this jar is picked up during the log4j build, but not mentioned in our dependencies page?
        Hide
        Gary Gregory added a comment -

        I recommend you use a build tool with dependency management like maven or ivy.

        Show
        Gary Gregory added a comment - I recommend you use a build tool with dependency management like maven or ivy.
        Hide
        Remko Popma added a comment - - edited

        Hi Dale,

        For some reason the log4j-core dependencies page mentions jackson-module-jaxb-annotations 2.4.1 but not jackson-annotations-2.4.1.

        Neither is explicitly included in the pom.xml for the log4j-core module. Not sure why Maven noticed the jackson-module-jaxb-annotations as a transitive dependency but not jackson-annotations.

        You can probably get the jar you need here:
        http://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations/2.4.1

        Show
        Remko Popma added a comment - - edited Hi Dale, For some reason the log4j-core dependencies page mentions jackson-module-jaxb-annotations 2.4.1 but not jackson-annotations-2.4.1. Neither is explicitly included in the pom.xml for the log4j-core module. Not sure why Maven noticed the jackson-module-jaxb-annotations as a transitive dependency but not jackson-annotations. You can probably get the jar you need here: http://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations/2.4.1
        Hide
        Dale Furrow added a comment -

        Added core, databind, dataformat-xml, dataformat-yaml and module-jaxb-annotions jars...still get error message on annotations. Checked dependencies lists--it appears to me these are the right jars.
        (1) Should configuration be changed--different jars perhaps? These are the files named under "Dependency Management".
        (2) If config requirements have changed since RC1, wouldn't it be a good idea to update the faq question "which jars do I need"?

        Show
        Dale Furrow added a comment - Added core, databind, dataformat-xml, dataformat-yaml and module-jaxb-annotions jars...still get error message on annotations. Checked dependencies lists--it appears to me these are the right jars. (1) Should configuration be changed--different jars perhaps? These are the files named under "Dependency Management". (2) If config requirements have changed since RC1, wouldn't it be a good idea to update the faq question "which jars do I need"?
        Hide
        Matt Sicker added a comment -

        The XMLLayout requires Jackson 2.x as well as the log4j-api and log4j-core JARs.

        Show
        Matt Sicker added a comment - The XMLLayout requires Jackson 2.x as well as the log4j-api and log4j-core JARs.
        Hide
        Dale Furrow added a comment -

        Screenshot from Intellij Idea IDE

        Show
        Dale Furrow added a comment - Screenshot from Intellij Idea IDE

          People

          • Assignee:
            Remko Popma
            Reporter:
            Dale Furrow
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development