Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8780811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:08:56+00:00 2026-06-13T20:08:56+00:00

I’m trying to develop mr-job using Cloudera hadoop distrubution.I’m using api version 2. I

  • 0

I’m trying to develop mr-job using Cloudera hadoop distrubution.I’m using api version 2.
I do get trouble with mr-unit. Please advice what to do. I’ve used standard arhetype and completely lost, I don’t get where is the rot of problem.
Here are my dependencies:

<dependency>
            <groupId>com.cloudera.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <version>0.20.2-320</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.cloudera.hadoop</groupId>
            <artifactId>hadoop-mrunit</artifactId>
            <version>0.20.2-320</version>
            <scope>test</scope>
        </dependency>

Here is my test code:

@Test
    public void testEmptyOutput() throws Exception{
        for(String line : linesFromFlatFile){
            //List<Pair<GetReq, IntWritable>> output = 
                    driver.withInput(UNUSED_LONG_KEY, new Text(line) )
                 // .withOutput(null, null )
                  .run();
            //assertTrue("", output.isEmpty());
        }
    }

And here is an exception:

> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.283
> sec <<< FAILURE!
> testEmptyOutput(MapperTest)
> Time elapsed: 0.258 sec  <<< ERROR! java.lang.NoSuchMethodError:
> org.apache.hadoop.mapreduce.TaskAttemptID.<init>(Ljava/lang/String;IZII)V
>   at
> org.apache.hadoop.mrunit.mapreduce.mock.MockMapContextWrapper$MockMapContext.<init>(MockMapContextWrapper.java:71)
>   at
> org.apache.hadoop.mrunit.mapreduce.mock.MockMapContextWrapper.getMockContext(MockMapContextWrapper.java:144)
>   at
> org.apache.hadoop.mrunit.mapreduce.MapDriver.run(MapDriver.java:197)
>   at
MapperTest.testEmptyOutput(ScoringCounterMapperTest.java:42)

package mypackage;

import java.util.Date;
import java.util.List;

import junit.framework.TestCase;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mrunit.mapreduce.MapDriver;
import org.apache.hadoop.mrunit.types.Pair;
import org.junit.Before;
import org.junit.Test;

import Sample;
import GetReq;



public class MapperTest extends TestCase {
    private static final IntWritable ONE_OCCURANCE = new IntWritable(1);
    private static final LongWritable UNUSED_LONG_KEY = new LongWritable(new Date().getTime());

    private Mapper<LongWritable, Text, GetReq, IntWritable> mapper;
    private MapDriver<LongWritable, Text, GetReq, IntWritable> driver;

    List<String> linesFromFlatFileNoOutput = null;
    List<String> linesFromFlatFileWithOutput = null;
    @Before 
    public void setUp() {
        mapper = newMapper();
        driver = new MapDriver<LongWritable, Text, GetReq, IntWritable>(mapper);
        Mapper.METADATA_CSV ="../../data/metadata.csv"; //ugly hook
        linesFromFlatFileNoOutput = Sample.instance.getLinesFromFlatFileNoOutput();  
        linesFromFlatFileWithOutput = Sample.instance.getLinesFromFlatFileWithOutput(); 
    }

    @Test
    public void testEmptyOutput() throws Exception{
        for(String line : linesFromFlatFileNoOutput){
            //List<Pair<GetReq, IntWritable>> output = 
                    driver.withInput(UNUSED_LONG_KEY, new Text(line) )
                  .withOutput(null, null )
                  .runTest();
            //assertTrue("", output.isEmpty());
        }
    }

    @Test
    public void testResultOutput() throws Exception{
        for(String line : linesFromFlatFileWithOutput){
            driver.withInput(UNUSED_LONG_KEY, new Text(line) )
                //.withOutput(null, null )
                .runTest();
        }
    }
}

Hm… I didn’t change anything in pom.xml
Now I get output and the same exeption. Looks like mapper runs once. Or rties to run. I get debug output from mapper body.

UPD: I’ve added classifier and changed dependency:

<dependency>
                <groupId>org.apache.mrunit</groupId>
                <artifactId>mrunit</artifactId>
                <version>0.9.0-incubating</version>
                <classifier>hadoop2</classifier>
                <scope>test</scope>
            </dependency>

Now I do get another problem:

Found interface org.apache.hadoop.mapreduce.Counter, but class was
expected

on line:

context.getCounter(EnumCounter.MATCHED_RECORDS).increment(1);

What do I do wrong again?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:08:57+00:00Added an answer on June 13, 2026 at 8:08 pm

    I’ve found the solution: Nee to add classifier tag for mr-unit. And It should look like:

    <dependency> 
    <groupId>org.apache.mrunit</groupId> 
    <artifactId>mrunit</artifactId> 
    <version>0.9.0-incubating</version> 
    <classifier>hadoop2</classifier> 
    <scope>test</scope> 
    </dependency> 
    

    Now I have another problem: Found interface org.apache.hadoop.mapreduce.Counter, but class was expected on counter increment. This problem is related to some bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.