java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskInputOutputContext, but class was expected

While writing the unit java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskInputOutputContext, but class was expected test cases for my
application I was getting the below mentioned exception during the execution of these test cases. Below is the  complete exception trace :

java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskInputOutputContext, but class was expected
	at org.apache.hadoop.mrunit.internal.mapreduce.AbstractMockContextWrapper.createCommon(
	at org.apache.hadoop.mrunit.internal.mapreduce.MockMapContextWrapper.create(
	at org.apache.hadoop.mrunit.internal.mapreduce.MockMapContextWrapper.(
	at org.apache.hadoop.mrunit.mapreduce.MapDriver.getContextWrapper(
	at org.apache.hadoop.mrunit.mapreduce.MapDriver.getContext(
	at com.techidiocy.integratekeys.mapreduce.test.TestIntegrationKeysMapper.init(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(
	at org.junit.internal.runners.statements.RunBefores.evaluate(
	at org.junit.internal.runners.statements.RunAfters.evaluate(
	at org.junit.runners.ParentRunner.runLeaf(
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
	at org.junit.runners.ParentRunner$
	at org.junit.runners.ParentRunner$1.schedule(
	at org.junit.runners.ParentRunner.runChildren(
	at org.junit.runners.ParentRunner.access$000(
	at org.junit.runners.ParentRunner$2.evaluate(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

By looking at the exception the first thing that came into my mind, am I using the correct version of org.apache.mrunit , and as expected when I checked my pom file I found that I am not using the correct version. Below is the dependency from my pom file.


Here if you notice the classifier that has been used in hadoop1 which provides all the libraries compatible to the code written with MR1 , but all of my hadoop related code has been written using MR2 so here was the version mismatch. One more thing from the stack trace it was clear that it was expecting some class but it found some interface , this points to one of the major changes that has been introduced in the MR2 api in comparison to MR1 api , most of the interfaces has been transformed into the concrete classes. One of the most common examples are your Mapper and Reducer classes in the new API.

Old API :

public interface Mapper<K1, V1, K2, V2> extends JobConfigurable, Closeable {


New API :

public class Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT> {}

For the resolution of the above mentioned exception I just changed the classifier from hadoop1 to hadoop2 and after that all the my unit test cases ran successfully. Below is the updated dependency for mrunit that I haved used in my pom file.


Suggestions ,corrections,questions are most welcomed.Disclaimer : All the logos and images used above belong to their respective owners.


    Saurabh Jain

    A Developer working on Enterprise applications ,Distributed Systems, Hadoop and BigData.This blog is about my experience working mostly on Java technologies ,NoSQL ,git , maven and Hadoop ecosystem.

    Share and Enjoy

    • Facebook
    • Twitter
    • Delicious
    • LinkedIn
    • StumbleUpon
    • Add to favorites
    • Email
    • RSS

    One thought on “java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskInputOutputContext, but class was expected

    Add Comment Register

    Leave a Reply to hadoop online training Cancel reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>