Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-15344

ClassCastException when reports are created with maven-site-plugin

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Duplicate
    • Component/s: findbugs-plugin
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      When enabling the Jenkins Findbugs plugin on a Maven job that uses the maven-site-plugin to generate the reports then the build fails with the root cause exception:
      java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
      (cf. attachment for full stack-trace).

        Attachments

        1. jenkins.txt
          11 kB
        2. test.zip
          3 kB

          Issue Links

            Activity

            zlika Thomas Zlika created issue -
            zlika Thomas Zlika made changes -
            Field Original Value New Value
            Link This issue is related to JENKINS-7666 [ JENKINS-7666 ]
            Hide
            drulli Ulli Hafner added a comment -

            Can you please add some details about your environment? Is this a slave build? Which JDK, findbugs, Jenkins, etc. is installed?

            Show
            drulli Ulli Hafner added a comment - Can you please add some details about your environment? Is this a slave build? Which JDK, findbugs, Jenkins, etc. is installed?
            zlika Thomas Zlika made changes -
            Environment The problem occurs at least on the following tested environments:
            - Jenkins 1.483 & 1.437 on both Windows and Linux
            - Multi-module Maven 3 project using Maven Findbugs plugin 2.5.2
            - JDK 1.7
            - It is not a slave build
            Hide
            zlika Thomas Zlika added a comment -

            I've updated the environment section of the issue. Tell me if you need other details.

            Show
            zlika Thomas Zlika added a comment - I've updated the environment section of the issue. Tell me if you need other details.
            Hide
            drulli Ulli Hafner added a comment -

            Please add the plug-in versions of findbugs and analysis-core. And how do you start Jenkins? java -jar or Tomcat?

            Note: does this error occur when Jenkins runs using a JDK 6?

            Show
            drulli Ulli Hafner added a comment - Please add the plug-in versions of findbugs and analysis-core. And how do you start Jenkins? java -jar or Tomcat? Note: does this error occur when Jenkins runs using a JDK 6?
            Hide
            zlika Thomas Zlika added a comment -

            analysis-core : 1.47
            findbugs : 4.44
            Starting Jenkins in standalone mode (java -jar) or deployed in a Tomcat server leads to the same problem.
            I've not tried with a JDK6 yet.

            Show
            zlika Thomas Zlika added a comment - analysis-core : 1.47 findbugs : 4.44 Starting Jenkins in standalone mode (java -jar) or deployed in a Tomcat server leads to the same problem. I've not tried with a JDK6 yet.
            Hide
            zlika Thomas Zlika added a comment -

            Just made a test with JRE6 : same problem.

            Show
            zlika Thomas Zlika added a comment - Just made a test with JRE6 : same problem.
            zlika Thomas Zlika made changes -
            Environment The problem occurs at least on the following tested environments:
            - Jenkins 1.483 & 1.437 on both Windows and Linux
            - Multi-module Maven 3 project using Maven Findbugs plugin 2.5.2
            - JDK 1.7
            - It is not a slave build
            The problem occurs at least on the following tested environments:
            - Jenkins 1.483 & 1.437 on both Windows and Linux
            - analysis-core plugin 1.47 and findbugs plugin 4.44
            - Multi-module Maven 3 project using Maven Findbugs plugin 2.5.2
            - JDK 1.7 or JRE1.6
            - Jenkins launched in standalone mode (java -jar jenkins.war) or deployed in a Tomcat server
            - It is not a slave build
            Hide
            zlika Thomas Zlika added a comment -

            According to the stack trace, it seems to be a class loading problem with dom4j.
            Using mvn dependency:tree, we can see that dom4j is used twice with 2 slightly different versions:

            • dom4j:dom4j:jar:1.6.1:compile is a transitive dependency of org.jvnet.hudson.plugins.findbugs:library:jar:2.0.1-SNAPSHOT
            • org.jvnet.hudson.dom4j:dom4j:jar:1.6.1-hudson-3:provided is a transitive dependency of org.jenkins-ci.main:jenkins-core:jar:1.409:provided

            In FindBugsParser.readXml(), where the bug occurs, you change the context class loader. And I can see in the stack trace that an async task is launched in a ThreadPoolExecutor, so the thread in the executor is certainly not using the class loader you tried to impose in FindBugsParser.readXml(), isn't it ?
            Maybe a quick-and-dirty workaround would be to explicitly exclude dom4j:dom4j:jar:1.6.1 when configuring the findbugs dependency ?

            Show
            zlika Thomas Zlika added a comment - According to the stack trace, it seems to be a class loading problem with dom4j. Using mvn dependency:tree, we can see that dom4j is used twice with 2 slightly different versions: dom4j:dom4j:jar:1.6.1:compile is a transitive dependency of org.jvnet.hudson.plugins.findbugs:library:jar:2.0.1-SNAPSHOT org.jvnet.hudson.dom4j:dom4j:jar:1.6.1-hudson-3:provided is a transitive dependency of org.jenkins-ci.main:jenkins-core:jar:1.409:provided In FindBugsParser.readXml(), where the bug occurs, you change the context class loader. And I can see in the stack trace that an async task is launched in a ThreadPoolExecutor, so the thread in the executor is certainly not using the class loader you tried to impose in FindBugsParser.readXml(), isn't it ? Maybe a quick-and-dirty workaround would be to explicitly exclude dom4j:dom4j:jar:1.6.1 when configuring the findbugs dependency ?
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Ulli Hafner
            Path:
            library/.classpath
            library/.project
            library/.settings/org.eclipse.core.resources.prefs
            library/.settings/org.eclipse.m2e.core.prefs
            library/pom.xml
            http://jenkins-ci.org/commit/findbugs-plugin/20fcf8f9fc4191842f63f2f3c27b1eb737fca247
            Log:
            [FIXED JENKINS-15344]: Upgrade to findbugs 2.0.1 and exclude DOM4J
            library which is already part of core.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: library/.classpath library/.project library/.settings/org.eclipse.core.resources.prefs library/.settings/org.eclipse.m2e.core.prefs library/pom.xml http://jenkins-ci.org/commit/findbugs-plugin/20fcf8f9fc4191842f63f2f3c27b1eb737fca247 Log: [FIXED JENKINS-15344] : Upgrade to findbugs 2.0.1 and exclude DOM4J library which is already part of core.
            scm_issue_link SCM/JIRA link daemon made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            Hide
            zlika Thomas Zlika added a comment -

            I tested the lattest version of Jenkins (1.484) with all the latest versions of the plugins (including analysis core 1.48 and findbugs 4.45) and unfortunately I still have the same error stack trace...

            Show
            zlika Thomas Zlika added a comment - I tested the lattest version of Jenkins (1.484) with all the latest versions of the plugins (including analysis core 1.48 and findbugs 4.45) and unfortunately I still have the same error stack trace...
            zlika Thomas Zlika made changes -
            Resolution Fixed [ 1 ]
            Status Resolved [ 5 ] Reopened [ 4 ]
            Hide
            drulli Ulli Hafner added a comment -

            Ok, I see. I just applied your quick fix with the hope that it will work on your machine...

            Show
            drulli Ulli Hafner added a comment - Ok, I see. I just applied your quick fix with the hope that it will work on your machine...
            Hide
            zlika Thomas Zlika added a comment -

            That was just a (bad) idea... I saw that the PMD plugin also comes with its own version of dom4j, but even if I delete it from the list of installed plugin the error still happens.
            Where you able to reproduce this problem on your machine or not ? I may try to build a small example so that you can reproduce the problem on your machine.

            Show
            zlika Thomas Zlika added a comment - That was just a (bad) idea... I saw that the PMD plugin also comes with its own version of dom4j, but even if I delete it from the list of installed plugin the error still happens. Where you able to reproduce this problem on your machine or not ? I may try to build a small example so that you can reproduce the problem on your machine.
            Hide
            drulli Ulli Hafner added a comment -

            That would help. I can't reproduce that problem on my machine up to now...

            Show
            drulli Ulli Hafner added a comment - That would help. I can't reproduce that problem on my machine up to now...
            drulli Ulli Hafner made changes -
            Link This issue is related to JENKINS-13718 [ JENKINS-13718 ]
            drulli Ulli Hafner made changes -
            Link This issue is related to JENKINS-13718 [ JENKINS-13718 ]
            Hide
            zlika Thomas Zlika added a comment -

            This very simple project (1 mock java class and 1 mock test class) can reproduce the problem.
            In fact the problem is not related to multi-module maven projects as I thought, because I can reproduce it with this mono-module project.
            The problem seems to be somehow related to the tests, because it disappears if I remove the test class.

            Show
            zlika Thomas Zlika added a comment - This very simple project (1 mock java class and 1 mock test class) can reproduce the problem. In fact the problem is not related to multi-module maven projects as I thought, because I can reproduce it with this mono-module project. The problem seems to be somehow related to the tests, because it disappears if I remove the test class.
            zlika Thomas Zlika made changes -
            Attachment test.zip [ 22630 ]
            Hide
            drulli Ulli Hafner added a comment -

            I can't reproduce this with your example. Is there a findbugs warning in your project? When I run it I get:

            [INFO] 
            [INFO] --- findbugs-maven-plugin:2.5.2:findbugs (default-cli) @ aggregator ---
            [INFO] Fork Value is true
            [INFO] Done FindBugs Analysis....
            mojoSucceeded org.codehaus.mojo:findbugs-maven-plugin:2.5.2(default-cli)
            [FINDBUGS] Finding all files that match the pattern findbugsXml.xml
            [FINDBUGS] Parsing 1 files in /Users/hafner/Development/jenkins/jobs/JENKINS-15344/workspace/target
            [FINDBUGS] Successfully parsed file /Users/hafner/Development/jenkins/jobs/JENKINS-15344/workspace/target/findbugsXml.xml of module aggregator with 0 warnings.
            projectSucceeded net.test:aggregator:0.1-SNAPSHOT
            sessionEnded
            
            

            There is no warning found. I'm using the goals "clean package findbugs:findbugs". What did you use?

            Show
            drulli Ulli Hafner added a comment - I can't reproduce this with your example. Is there a findbugs warning in your project? When I run it I get: [INFO] [INFO] --- findbugs-maven-plugin:2.5.2:findbugs (default-cli) @ aggregator --- [INFO] Fork Value is true [INFO] Done FindBugs Analysis.... mojoSucceeded org.codehaus.mojo:findbugs-maven-plugin:2.5.2(default-cli) [FINDBUGS] Finding all files that match the pattern findbugsXml.xml [FINDBUGS] Parsing 1 files in /Users/hafner/Development/jenkins/jobs/JENKINS-15344/workspace/target [FINDBUGS] Successfully parsed file /Users/hafner/Development/jenkins/jobs/JENKINS-15344/workspace/target/findbugsXml.xml of module aggregator with 0 warnings. projectSucceeded net.test:aggregator:0.1-SNAPSHOT sessionEnded There is no warning found. I'm using the goals "clean package findbugs:findbugs". What did you use?
            Hide
            zlika Thomas Zlika added a comment -

            I use mvn clean site

            Show
            zlika Thomas Zlika added a comment - I use mvn clean site
            drulli Ulli Hafner made changes -
            Link This issue is related to JENKINS-14737 [ JENKINS-14737 ]
            drulli Ulli Hafner made changes -
            Summary Publishing Findbugs analysis report on a multi-module maven project results in ClassCastException ClassCastException when reports are created with maven-site-plugin
            Priority Major [ 3 ] Minor [ 4 ]
            Description When using the Jenkins Findbugs plugin on a multi-module Maven plugin, the build fails with the root cause exception:
            java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
            (cf. attachment for full stack-trace).

            Note: the Findbugs Maven plugin is not able to generate an aggregated report for multi-module Maven, so maybe this is the origin of the problem ?
            When enabling the Jenkins Findbugs plugin on a Maven job that uses the maven-site-plugin to generate the reports then the build fails with the root cause exception:
            java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
            (cf. attachment for full stack-trace).
            Hide
            drulli Ulli Hafner added a comment -

            Thanks Thomas! Now I can reproduce the problem. Seems that maven-site-plugin is the cause for the exception. I need to investigate how I can update my plug-in to work with the results of this maven plugin.

            Until that is fixed, please use the goal 'findbugs:findbugs' to create the FindBugs results. Maybe it would also work if you downgrade to 3.0 maven-site-plugin, see JENKINS-14737.

            Show
            drulli Ulli Hafner added a comment - Thanks Thomas! Now I can reproduce the problem. Seems that maven-site-plugin is the cause for the exception. I need to investigate how I can update my plug-in to work with the results of this maven plugin. Until that is fixed, please use the goal 'findbugs:findbugs' to create the FindBugs results. Maybe it would also work if you downgrade to 3.0 maven-site-plugin, see JENKINS-14737 .
            Hide
            zlika Thomas Zlika added a comment -

            "mvn clean site" works indeed with maven site plugin 3.0, but not with 3.1 or 3.2.
            I have also found another workaround: the bug vanishes if instead of doing "mvn clean site" I do "mvn clean install site" !

            Show
            zlika Thomas Zlika added a comment - "mvn clean site" works indeed with maven site plugin 3.0, but not with 3.1 or 3.2. I have also found another workaround: the bug vanishes if instead of doing "mvn clean site" I do "mvn clean install site" !
            Hide
            famod Falko Modler added a comment -

            Any updates? I just had to downgrade to maven-site-plugin 3.0.

            Show
            famod Falko Modler added a comment - Any updates? I just had to downgrade to maven-site-plugin 3.0.
            Hide
            drulli Ulli Hafner added a comment -

            @Falko: did you try the workaround noted by Thomas?

            This issue is not on my priority list So feel free to provide a patch if the workaround is not working in your environment...

            Show
            drulli Ulli Hafner added a comment - @Falko: did you try the workaround noted by Thomas? This issue is not on my priority list So feel free to provide a patch if the workaround is not working in your environment...
            Hide
            drulli Ulli Hafner added a comment -

            I tried some ideas to get the plug-in correctly running with new site plugin, however nothing worked. I think that this actually is a problem in the class loaders of the maven plug-in in Jenkins core... Seems that they are new isolated enough.

            Show
            drulli Ulli Hafner added a comment - I tried some ideas to get the plug-in correctly running with new site plugin, however nothing worked. I think that this actually is a problem in the class loaders of the maven plug-in in Jenkins core... Seems that they are new isolated enough.
            kinow Bruno P. Kinoshita made changes -
            Link This issue is related to JENKINS-17488 [ JENKINS-17488 ]
            bdellegrazie Brett Delle Grazie made changes -
            Link This issue is duplicated by JENKINS-13709 [ JENKINS-13709 ]
            bdellegrazie Brett Delle Grazie made changes -
            Link This issue is duplicated by JENKINS-13709 [ JENKINS-13709 ]
            bdellegrazie Brett Delle Grazie made changes -
            Link This issue is related to JENKINS-13709 [ JENKINS-13709 ]
            ndeloof Nicolas De Loof made changes -
            Link This issue is duplicated by JENKINS-13709 [ JENKINS-13709 ]
            Hide
            ahorst Andreas Horst added a comment -

            I can still confirm this on 1.574 with maven-site-plugin 3.3. Also the workaround to additionally invoke the default lifecycle (e.g. "clean package site-deploy") works. Though it would be nice to be able to just do a "clean site-deploy" in a dedicated site job.

            Show
            ahorst Andreas Horst added a comment - I can still confirm this on 1.574 with maven-site-plugin 3.3. Also the workaround to additionally invoke the default lifecycle (e.g. "clean package site-deploy") works. Though it would be nice to be able to just do a "clean site-deploy" in a dedicated site job.
            Hide
            kohsuke Kohsuke Kawaguchi added a comment -

            Dupliate of JENKINS-13709.

            Show
            kohsuke Kohsuke Kawaguchi added a comment - Dupliate of JENKINS-13709 .
            kohsuke Kohsuke Kawaguchi made changes -
            Status Reopened [ 4 ] Resolved [ 5 ]
            Assignee Ulli Hafner [ drulli ] Kohsuke Kawaguchi [ kohsuke ]
            Resolution Duplicate [ 3 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 146067 ] JNJira + In-Review [ 191770 ]

              People

              • Assignee:
                kohsuke Kohsuke Kawaguchi
                Reporter:
                zlika Thomas Zlika
              • Votes:
                10 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: