Unit tests passing through Maven, but failing through Cobertura: "Expecting a stackmap frame at branch target 65"
Asked Answered
J

2

19

I recently added the Cobertura plugin to my Java/Spring-MVC project. The strange thing is that all my unit tests were passing, and they still pass when Maven does its initial test run, but then when Cobertura tries to run the tests, they all fail with the same error message:

Expecting a stackmap frame at branch target 65 in method xxx.xxxx.xxxx.xxxx;)V at offset 40

I have no idea why this is happening and don't even know how to go about fixing it. I've searched the internet but haven't found any similar problems. I use JUnit and spring-test-mvc for testing.

Has anyone seen this before?

Jillianjillie answered 6/8, 2013 at 15:30 Comment(2)
This seems to be a common problem, with very similar questions posted on SO. I posted the resolution to our problem was resolved with this: https://mcmap.net/q/667310/-cobertura-doesn-39-t-work-with-java-7Lenssen
I met the same problem when using cobertura-maven-plugin version 2.4. It worked for both of JDK_1.7.0_79 and JDK_1.8.0_45 when I upgraded cobertura-maven-plugin to version 2.7.Cruickshank
J
19

Of course I find the answer right after asking the question, even though I searched for quite awhile before...

The problem is that Cobertura has trouble working with Java 1.7. You must add the following line to your pom.xml:

<argLine>-XX:-UseSplitVerifier</argLine>

That goes in the configuration element. Here is the entire Cobertura section:

     <plugin>
        <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <argLine>-XX:-UseSplitVerifier</argLine>
                <formats>
                    <format>xml</format>
                </formats>
            </configuration>
            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>cobertura</goal>
                    </goals>
                </execution>
            </executions>
       </plugin>

Now everything works as expected.

Jillianjillie answered 6/8, 2013 at 15:42 Comment(1)
Cobertura 2.6 also fixes this.Dally
C
5

Fixed by using new plugin

                  <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>cobertura-maven-plugin</artifactId>
                        <version>2.7</version>
                        <configuration>
                            <formats>
                                <format>xml</format>
                            </formats>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>cobertura</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
Coexist answered 9/2, 2017 at 20:33 Comment(1)
YES! I tried the -noverify, tried the -XX:-UseSplitVerifier and had no luck. I'm using java 1.8 and this is what worked for me. spent 4 hours on this! Hope other people with the same issue come across this answerPeppers

© 2022 - 2024 — McMap. All rights reserved.