4

I have recently set up a pseudo-distributed hadoop 2.2.0 cluster on my Mac OSX following this guide. Then, I tried the basic Cascading file copy with Cascading 2.5.1 However when I compiled the project using maven, I got the following error:

[ERROR] /Users/david/IdeaProjects//CascadingIntro/src/main/java/com/example/CascadingIntro.java:[24,24] 
cannot access org.apache.hadoop.mapred.JobConf
class file for org.apache.hadoop.mapred.JobConf not found

What am I doing wrong and how do I fix this? I believe that Cascading 2.5.1 is compatible with Hadoop 2.2.0 from this page on Cascading.org.

My pom.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>CascadingIntro</groupId>
<artifactId>CascadingIntro</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
    <repository>
        <id>conjars.org</id>
        <url>http://conjars.org/repo</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>cascading</groupId>
        <artifactId>cascading-core</artifactId>
        <version>2.5.1</version>
    </dependency>
    <dependency>
        <groupId>cascading</groupId>
        <artifactId>cascading-hadoop</artifactId>
        <version>2.5.1</version>
    </dependency>
</dependencies>
<build>
    <finalName>CascadingIntro</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.example.CascadingIntro</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

And in my CascadingIntro class:

package com.example;

import cascading.flow.FlowDef;
import cascading.flow.hadoop.HadoopFlowConnector;
import cascading.pipe.Pipe;
import cascading.property.AppProps;
import cascading.scheme.hadoop.TextDelimited;
import cascading.tap.Tap;
import cascading.tap.hadoop.Hfs;

import java.util.Properties;

public class CascadingIntro {


    public static void main(String[] args) {

        Properties properties = new Properties();
        AppProps.setApplicationJarClass( properties, CascadingIntro.class );

        HadoopFlowConnector flowConnector = new HadoopFlowConnector( properties );

        String inputPath = args[0];
        Tap inputTap = new Hfs(new TextDelimited(true,"\t"), inputPath);

        String outputPath = args[1];
        Tap outputTap = new Hfs(new TextDelimited(true,"\t"),outputPath);

        Pipe copyPipe = new Pipe("copy");

        FlowDef flowDef = FlowDef
            .flowDef()
            .addSource(copyPipe,inputTap)
            .addTailSink(copyPipe,outputTap);

        flowConnector.connect(flowDef).complete();
    }
}
David Williams
  • 8,388
  • 23
  • 83
  • 171

1 Answers1

5

You need to add hadoop-client to your dependencies:

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-client</artifactId>
    <version>2.2.0</version>
</dependency>
Jakub Kotowski
  • 7,411
  • 29
  • 38
  • Thank you for the answer, I added that, but got this: `Exception in thread "main" java.lang.NoClassDefFoundError: cascading/scheme/Scheme Caused by: java.lang.ClassNotFoundException: cascading.scheme.Scheme` ideas? One sec, might just be the classpath, right? – David Williams Dec 26 '13 at 22:14
  • I added all dependencies with the assembly plugin, but I get this right at the beginning of the mr job `Exception in thread "main" cascading.flow.planner.PlannerException: could not build flow from assembly: [invalid field type (null); must be String or Integer: ]` This might be a compatibility thing: https://groups.google.com/forum/#!topic/cascading-user/ti3uOTM6xRU . Your thoughts? – David Williams Dec 26 '13 at 22:55
  • `"Works for me"`: Any chance you can tarball up the solution and put it for download? – David Williams Dec 30 '13 at 17:58
  • http://www.ulozto.net/xsnY9sKs/hadoop-file-copy-tar-gz ...it's ~22MB because I included target/ with the assembled job jar. I also added a simple run script. – Jakub Kotowski Jan 01 '14 at 15:02
  • Thanks for that, I had a thorough read, and it compiled well. Quick question, do you know how I tell Cascading to look in hdfs rather than the local file system for the copy? – David Williams Jan 01 '14 at 18:47
  • No problem. Cascading executes in local mode by default and in that mode you cannot access hdfs. Simply run the job on a cluster like `$ /opt/hadoop/bin/hadoop jar target/CascadingIntro-1.0-SNAPSHOT-job.jar com.example.CascadingIntro testInput.txt testInput.txt_copied` and in this case `testInput.txt` is already a relative hdfs path (relative to `/hadoop/user/${hadoop_username}/`). – Jakub Kotowski Jan 01 '14 at 19:20