5

I am using maven 3.0.4, JRE 1.7.0_09. When I use mvn clean install all my tests passes and everything looks good - here is my surefire plugin configuration:

<plugin>
    <version>2.12.4</version>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <!-- -XX:-UseSplitVerifier is for java 7 -->
        <argLine>-XX:-UseSplitVerifier</argLine>
    </configuration>
</plugin> 

Now, when I mvn cobertura:cobertura some of my tests have errors like this one:

Expecting a stackmap frame at branch target .... And some more errors that made me understand that it is not running using JRE7 (for example, Encountered " "|" "| "" at line...)

Here is my cobertura plugin configuration:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.5.1</version>
    <configuration>
       <formats>
          <format>html</format>
          <format>xml</format>
       </formats>
       </configuration>
  </plugin>

And the reporting is:

<reporting>
    <plugins>
        <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>cobertura-maven-plugin</artifactId>
           <version>2.5.1</version>
           <configuration>
               <formats>
                   <format>html</format>
                   <format>xml</format>
               </formats>
            </configuration>
        </plugin>
    </plugins>
</reporting>

I saw a lot of threads that talk about this issue and the solution is to add this line <argLine>-XX:-UseSplitVerifier</argLine> but it does not help.

What am I doing wrong here?

Community
  • 1
  • 1
Noam
  • 3,049
  • 10
  • 34
  • 52
  • 1
    If you're not bound to cobertura, I'd recommend going JaCoCo which has full java 7 support and is being actively maintained. Cobertura seems pretty dead. – Michel Jung Jun 16 '13 at 17:32
  • Thanks, I'm trying it and I got a new [question](http://stackoverflow.com/questions/17187029/how-to-run-jacoco-with-java-7-and-spring-instrument) about it. – Noam Jun 19 '13 at 08:59
  • The split verifier thing worked for me .. – mhvelplund Jul 22 '13 at 14:43
  • @MichelJung - Hmmm, I tried jacoco, and coverage dropped dramatically - on one project, from 97.4% to 81.1%. Is that typical? – Don Branson Nov 12 '13 at 22:37
  • JaCoCo does not work with PowerMock bytecode instrumentation. That is, any class that you @PrepareForTest with PowerMock will not be counted in your code coverage with JaCoCo. (https://github.com/jacoco/eclemma/issues/15) – Spencer Feb 27 '14 at 19:00

3 Answers3

5

We are using Cobertura plugin version 2.6 with Java 7 with no problems. This includes some files with Java 7 syntax (multi-catch, e.g.) which used to fail with the earlier plugin version. Nor do I need to use -XX:-UseSplitVerifier in the SureFire plugin any longer.

<properties>
    <coberturaMavenPlugin>2.6</coberturaMavenPlugin>
    <mavenSurefirePlugin>2.12</mavenSurefirePlugin>
</properties>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${mavenSurefirePlugin}</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>${coberturaMavenPlugin}</version>
            <configuration>
                <aggregate>true</aggregate>
            </configuration>
        </plugin>
    </plugins>
</reporting>
Spencer
  • 473
  • 6
  • 13
1

Further to this, the issue we had was to do with Cobertura and the version of Xalan/Xerces.

Looking at http://mojo.codehaus.org/cobertura-maven-plugin/dependencies.html, it can be seen that the cobertura plugin has Transitive Dependencies on Xalan 2.6.0 & Xerces at 2.6.2.

To combat this, I added:

<dependency>
    <groupId>xalan</groupId>
    <artifactId>xalan</artifactId>
    <version>2.7.1</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.11.0</version>
    <scope>test</scope>
</dependency>

And the tests passed, both during the initial test phase with surefire and the cobertura phase.

theINtoy
  • 3,388
  • 2
  • 37
  • 60
  • The issue we had with xalan and xerces was an incompatibility with Mozilla Rhino: https://groups.google.com/forum/#!topic/mozilla.dev.tech.js-engine.rhino/H66G98NlkHM – ahawtho Jun 09 '14 at 20:15
0

Perhaps you can set the compiler source and target version options to version "1.6" Different versions of build tools may choose different defaults for this setting. (Buildr 1.4 defaults to source and target 1.7 these days; Maven 2.x still uses 1.6 or earlier.)

Dzhaughn
  • 114
  • 1
  • 4