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. jenkins.txt
          11 kB
        2. test.zip
          3 kB

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

          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.

          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.

          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?

          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?

          Thomas Zlika added a comment -

          I use mvn clean site

          Thomas Zlika added a comment - I use mvn clean site

          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.

          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 .

          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" !

          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" !

          Falko Modler added a comment -

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

          Falko Modler added a comment - Any updates? I just had to downgrade to maven-site-plugin 3.0.

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

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

          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.

          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.

          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.

          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.

          Dupliate of JENKINS-13709.

          Kohsuke Kawaguchi added a comment - Dupliate of JENKINS-13709 .

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

              Created:
              Updated:
              Resolved: