运行mrunit报错问题该怎么解决

93次阅读
没有评论

这篇文章给大家介绍运行 mrunit 报错问题该怎么解决,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

在看 hadoop 权威指南的时候,运行 mrunit 的例子(MaxTemperatureMapperTest)的时候,报出一个异常,网上查了资料后,是 mrunit 的版本问题,可以结合 hadoop 的版本,找到对应的 mrunit 的版本。

另外,我在找 mrunit 的过程中,因为 http://mvnrepository.com/  提供的 mrunit 不能下载,就自己随便找了一个,上传到我的 nexus 服务器上用了,但是在运行的过程中,还是存在一些问题,主要是 mrunit 还依赖了其他两个 jar(mockito-all 和 powermock-api-mockito), 在 pom.xml 中同时加上这两个依赖,同时注意这两个 jar 的版本问题。

java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskInputOutputContext, but class was expected
 at org.apache.hadoop.mrunit.mapreduce.mock.MockContextWrapper.createCommon(MockContextWrapper.java:51)
 at org.apache.hadoop.mrunit.mapreduce.mock.MockMapContextWrapper.create(MockMapContextWrapper.java:65)
 at org.apache.hadoop.mrunit.mapreduce.mock.MockMapContextWrapper. init (MockMapContextWrapper.java:57)
 at org.apache.hadoop.mrunit.mapreduce.MapDriver.run(MapDriver.java:195)
 at org.apache.hadoop.mrunit.MapDriverBase.runTest(MapDriverBase.java:185)
 at v1.MaxTemperatureMapperTest.processesValidRecord(MaxTemperatureMapperTest.java:22)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:601)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
dependency 
 groupId org.apache.hadoop /groupId 
 artifactId mrunit /artifactId 
 version 1.1.0 /version 
 classifier hadoop2 /classifier 
 /dependency 
 dependency 
 groupId org.mockito /groupId 
 artifactId mockito-all /artifactId 
 version 1.10.19 /version 
 /dependency 
 dependency 
 groupId org.powermock /groupId 
 artifactId powermock-api-mockito /artifactId 
 version 1.6.4 /version 
 /dependency

关于运行 mrunit 报错问题该怎么解决就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。