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

ClassCastException when reports are created with maven-site-plugin

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • findbugs-plugin
    • None

      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).

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

          [JENKINS-15344] ClassCastException when reports are created with maven-site-plugin

          Thomas Zlika created issue -
          Thomas Zlika made changes -
          Link New: This issue is related to JENKINS-7666 [ JENKINS-7666 ]

          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?

          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?
          Thomas Zlika made changes -
          Environment New: 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

          Thomas Zlika added a comment -

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

          Thomas Zlika added a comment - I've updated the environment section of the issue. Tell me if you need other details.

          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?

          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?

          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.

          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.

          Thomas Zlika added a comment -

          Just made a test with JRE6 : same problem.

          Thomas Zlika added a comment - Just made a test with JRE6 : same problem.
          Thomas Zlika made changes -
          Environment Original: 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
          New: 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

          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 ?

          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 ?

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

              Created:
              Updated:
              Resolved: