Mojo's Cobertura Maven Plugin
  1. Mojo's Cobertura Maven Plugin
  2. MCOBERTURA-53

Classcast Exception in Cobertura net.sourceforge.cobertura.coveragedata.PackageData

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.1
    • Fix Version/s: 2.5
    • Labels:
      None
    • Environment:
      Windows XP
      JDK 1.5.0_09
      Maven 2.0.4
    • Number of attachments :
      0

      Description

      [INFO] Generate "Cobertura Test Coverage" report.
      [DEBUG] Working Directory: null
      [DEBUG] Executing command line:
      [DEBUG] java -cp ";C:\Documents and Settings\jhenry\.m2\repository\commons-validator\commons-validator\1.1.4\commons-validator-1.1.4.jar;C:\Documents
      and Settings\jhenry\.m2\repository\cobertura\cobertura-runtime\1.8\cobertura-runtime-1.8.pom;C:\Documents and Settings\jhenry\.m2\repository\urbanophi
      le\java-getopt\1.0.9\java-getopt-1.0.9.jar;C:\Documents and Settings\jhenry\.m2\repository\oro\oro\2.0.8\oro-2.0.8.jar;C:\Documents and Settings\jhenr
      y\.m2\repository\doxia\doxia-core\1.0-alpha-4\doxia-core-1.0-alpha-4.jar;C:\Documents and Settings\jhenry\.m2\repository\asm\asm\2.2.1\asm-2.2.1.jar;C
      :\Documents and Settings\jhenry\.m2\repository\log4j\log4j\1.2.9\log4j-1.2.9.jar;C:\Documents and Settings\jhenry\.m2\repository\cobertura\cobertura\1
      .8\cobertura-1.8.jar;C:\Documents and Settings\jhenry\.m2\repository\org\apache\maven\reporting\maven-reporting-impl\2.0\maven-reporting-impl-2.0.jar;
      D:\jhenry\maven-2.0.4\core\plexus-container-default-1.0-alpha-9.jar;D:\jhenry\maven-2.0.4\core\plexus-utils-1.1.jar;D:\jhenry\maven-2.0.4\lib\maven-pr
      oject-2.0.4.jar;D:\jhenry\maven-2.0.4\lib\maven-reporting-api-2.0.4.jar;D:\jhenry\maven-2.0.4\lib\maven-artifact-2.0.4.jar;D:\jhenry\maven-2.0.4\lib\m
      aven-plugin-api-2.0.4.jar" -Dlog4j.configuration=file:/C:/DOCUME~1/jhenry/LOCALS~1/Temp/log4j61215config.properties -Xmx64m net.sourceforge.cobertura.
      reporting.Main --source D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\src\main\java --source D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\src\main\ja
      va --source D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\src\main\java --destination D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\target\site\cobert
      ura --datafile D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\target\cobertura\cobertura.ser --format html
      [DEBUG] exit code: 1
      [DEBUG] --------------------
      [DEBUG] Standard output from the Cobertura task:
      [DEBUG] --------------------
      [INFO] Cobertura 1.8 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
      [cobertura] DEBUG [main] net.sourceforge.cobertura.util.FileFinder - Adding sourceDirectory=[--source]
      [cobertura] DEBUG [main] net.sourceforge.cobertura.util.FileFinder - Adding sourceDirectory=[D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\src\main\ja
      va]
      [cobertura] DEBUG [main] net.sourceforge.cobertura.util.FileFinder - Adding sourceDirectory=[--source]
      [cobertura] DEBUG [main] net.sourceforge.cobertura.util.FileFinder - Adding sourceDirectory=[D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\src\main\ja
      va]
      [cobertura] DEBUG [main] net.sourceforge.cobertura.util.FileFinder - Adding sourceDirectory=[--source]
      [cobertura] DEBUG [main] net.sourceforge.cobertura.util.FileFinder - Adding sourceDirectory=[D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\src\main\ja
      va]
      [cobertura] DEBUG [main] net.sourceforge.cobertura.reporting.Main - format is html
      [cobertura] DEBUG [main] net.sourceforge.cobertura.reporting.Main - dataFile is D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\target\cobertura\cobertu
      ra.ser
      [cobertura] DEBUG [main] net.sourceforge.cobertura.reporting.Main - destinationDir is D:\jhenry\jwebunit-1.x\jwebunit-commons-tests\target\site\cobert
      ura
      Cobertura: Loaded information on 24 classes.

      [DEBUG] --------------------
      [DEBUG] --------------------
      [DEBUG] Standard error from the Cobertura task:
      [DEBUG] --------------------
      [ERROR] Exception in thread "main" java.lang.ClassCastException: net.sourceforge.cobertura.coveragedata.SourceFileData
      at net.sourceforge.cobertura.coveragedata.PackageData.getSourceFiles(PackageData.java:112)
      at net.sourceforge.cobertura.coveragedata.ProjectData.getSourceFiles(ProjectData.java:111)
      at net.sourceforge.cobertura.reporting.html.HTMLReport.generateSourceFileList(HTMLReport.java:173)
      at net.sourceforge.cobertura.reporting.html.HTMLReport.generateSourceFileLists(HTMLReport.java:156)
      at net.sourceforge.cobertura.reporting.html.HTMLReport.<init>(HTMLReport.java:83)
      at net.sourceforge.cobertura.reporting.Main.parseArguments(Main.java:100)
      at net.sourceforge.cobertura.reporting.Main.main(Main.java:161)

      [DEBUG] --------------------
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Error during page generation

        Activity

        Hide
        the_dragon added a comment -

        I have the same problem. Also if the cobertura.ser file wasn't created before (e.g. after cleaning the target directory), I get this exception:

        [ERROR] Cobertura: Error writing file D:\projects\istnatives\target\cobertura\cobertura.ser
        java.io.FileNotFoundException: D:\projects\istnatives\target\cobertura\cobertura.ser (Das System kann den ange
        gebenen Pfad nicht finden)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler.saveCoverageData(CoverageDataFileHan
        dler.java:135)
        at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:472)
        at net.sourceforge.cobertura.instrument.Main.main(Main.java:489)

        The german part in there means that the file couldn't be found.
        This happens with the latest version, the older one based on Cobertura 1.7 worked as it should.

        In some projects there is no build error (also we are using almost the same pom in all of them), but there the line coverage is always 100% and the branch coverage is on 0%.

        Show
        the_dragon added a comment - I have the same problem. Also if the cobertura.ser file wasn't created before (e.g. after cleaning the target directory), I get this exception: [ERROR] Cobertura: Error writing file D:\projects\istnatives\target\cobertura\cobertura.ser java.io.FileNotFoundException: D:\projects\istnatives\target\cobertura\cobertura.ser (Das System kann den ange gebenen Pfad nicht finden) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.<init>(Unknown Source) at java.io.FileOutputStream.<init>(Unknown Source) at net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler.saveCoverageData(CoverageDataFileHan dler.java:135) at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:472) at net.sourceforge.cobertura.instrument.Main.main(Main.java:489) The german part in there means that the file couldn't be found. This happens with the latest version, the older one based on Cobertura 1.7 worked as it should. In some projects there is no build error (also we are using almost the same pom in all of them), but there the line coverage is always 100% and the branch coverage is on 0%.
        Hide
        Binil Thomas added a comment -

        Meanwhile, you can get around this by fixing the plugin version to be 2.0.
        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.0</version>
        <executions>
        <execution>
        <id>clean</id>
        <goals>
        <goal>clean</goal>
        </goals>
        </execution>
        </executions>
        </plugin>

        Show
        Binil Thomas added a comment - Meanwhile, you can get around this by fixing the plugin version to be 2.0. <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.0</version> <executions> <execution> <id>clean</id> <goals> <goal>clean</goal> </goals> </execution> </executions> </plugin>
        Hide
        Damien Lecan added a comment -

        It's a serious regression I think

        Plugin 2.0 cannot be used because of MCOBERTURA-39 for example in a multi-project build

        Show
        Damien Lecan added a comment - It's a serious regression I think Plugin 2.0 cannot be used because of MCOBERTURA-39 for example in a multi-project build
        Hide
        md added a comment -

        I am seeing this with maven 2.0.5 and jdk 1.5.0.
        I switched from cobertura 2.0 and maven 2.0.4 because I have been getting and "unable to execute cobetura" problems on one of my modules, in the hope that the newer versions would have fixed it. Instead, the newer ones seem to have regressed even more. It is surprising that one of the most important plugins from a TDD perpective is itself so buggy. I hope this bug gets the right attention.

        Show
        md added a comment - I am seeing this with maven 2.0.5 and jdk 1.5.0. I switched from cobertura 2.0 and maven 2.0.4 because I have been getting and "unable to execute cobetura" problems on one of my modules, in the hope that the newer versions would have fixed it. Instead, the newer ones seem to have regressed even more. It is surprising that one of the most important plugins from a TDD perpective is itself so buggy. I hope this bug gets the right attention.
        Hide
        Dennis Lundberg added a comment -

        A sample project that reproduces this problem would be helpful.

        Show
        Dennis Lundberg added a comment - A sample project that reproduces this problem would be helpful.
        Hide
        Bryan Ward added a comment -

        I'm getting the same problem however I noticed that it only occurs when the report format is html. Generating the xml report works fine.

        Show
        Bryan Ward added a comment - I'm getting the same problem however I noticed that it only occurs when the report format is html. Generating the xml report works fine.
        Hide
        Benson Margulies added a comment -

        three years+ and no test case; closing.

        Show
        Benson Margulies added a comment - three years+ and no test case; closing.

          People

          • Assignee:
            Unassigned
            Reporter:
            Julien HENRY
          • Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: