0

I upgraded the MRUnit version to 1.1.0 in my project, to use the ReduceDriver for testing multiple outputs. After making changes to my test (to make it work with the upgrade), I get this error:

java.lang.VerifyError: Expecting a stackmap frame at branch target 63
Exception Details:
Location: (path to test class)
Reason: Expected stackmap frame at this location.
Bytecode: (Bytecode)

My test looks like this (have deliberately removed code to make this more concise):

@RunWith(PowerMockRunner.class)
@PrepareForTest(MultipleOutputs.class)
public class myReducerTest {
   private ReduceDriver<Text, Text, Text, Text> reduceDriver;

   @Before
   public void setUp() {
       reduceDriver = ReduceDriver.newReduceDriver(new myReducer());
   }

   @Test
   public void testHappyPath() throws IOException {
       /*
          Code to declare input key, inout value, expected output, etc.
       */

       reduceDriver.withInput(myInputKey, myInputVal);
       reduceDriver.withMultiOutput("reportName1", key, expectedValue1);
       reduceDriver.withMultiOutput("reportName2", key, expectedValue2);
       reduceDriver.runTest();
   }
}

I get the error when I use @PrepareForTest. Note that myReducer class has no static or final methods. That is why it is not included in @PrepareForTest annotation. Part of my pom file (I am using maven for building) looks like this:

    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-core</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-easymock</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.mrunit</groupId>
        <artifactId>mrunit</artifactId>
        <version>1.1.0</version>
        <classifier>hadoop2</classifier>
        <scope>test</scope>
    </dependency>

Also note that I am using Java 8, and cannot downgrade to v7 or v6 as mentioned here: java.lang.VerifyError: Expecting a stackmap frame at branch target

I also tried adding the surefire plugin in the pom file, as mentioned here: java.lang.VerifyError: Expecting a stackmap frame at branch target 73

None of these solutions work in this case.

Community
  • 1
  • 1
Sarin
  • 197
  • 3
  • 13
  • If you think, that anybody suggested adding the surefire plugin to your pom file, you have to work on your reading skills. Really. (And with “reading” I mean “reading and understanding”). I could try to explain further, but if you will read my explanation the same way you read the linked answer, it won’t help. – Holger Jun 06 '16 at 12:09
  • @Holger I am new to Java. Maven picks up everything from the POM file while building, so I made an assumption. Check this link http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html Plugin info is under Project/Build – Sarin Jun 06 '16 at 21:52
  • This has nothing to do with Java. This is only about reading a text and understanding what it says. Nobody said that you should install that plugin. Try to understand the previous sentence. – Holger Jun 07 '16 at 08:34
  • Hint: if you are really new to Java, then for your own sake: stay away from PowerMock. PowerMock causes more trouble than good. – GhostCat Jun 09 '16 at 09:41
  • @Jägermeister I have to use PowerMock because the MultipleOutputs class has static methods. Even the ReduceDriver (which is part of MRUnit package) is using PowerMock. Can you suggest alternatives to PowerMock? – Sarin Jun 09 '16 at 19:52

3 Answers3

1

Maybe you can check this issue. In my case, change to the latest version that worked.Now, my version is 2.0.7

<properties>
    <powermock.version>2.0.7</powermock.version>
</properties>
Jess Chen
  • 3,136
  • 1
  • 26
  • 35
0

I had a similar problem and found this link: https://github.com/jayway/powermock/issues/375.

MRunit 1.1.0 uses PowerMock 1.5.1. which uses JavaAssist 3.18.0-GA.
JavaAssist 3.18.2-GA contains a fix for the verifyError.

Exclude the old PowerMock dependency in MRUnit and replace it with PowerMock 1.5.5 or higher. These PowerMock versions contain the fixed JavaAssist version.

    <dependency> (all PowerMock dependencies)
        ... PowerMock dependency ...
        <version>1.5.5(or higher)</version>
    </dependency>

    <dependency>
        <groupId>org.apache.mrunit</groupId>
        <artifactId>mrunit</artifactId>
        <version>1.1.0</version>
        <exclusions>
            ...insert all PowerMock exclusions...
        </exclusions>
        <classifier>hadoop2</classifier>
        <scope>test</scope>
    </dependency>
Thogor
  • 321
  • 2
  • 7
-2

As a temporary fix you can add -noverify to your JVM arguments. Do not use this in any release though.

Display Name
  • 942
  • 1
  • 10
  • 20