错误包org.apache.pig.FilterFunc不存在

时间:2015-12-15 08:26:06

标签: java hadoop apache-pig bigdata

我可以问一个问题,我已经安装并配置了Pig,但它说" error package org.apache.pig.FilterFunc not exist"我正在尝试使用javac命令编译一个非常简单的java源文件。

CLASSPATH变量的设置如下:

/usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.0.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.0.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-cli-1.2.jar:/usr/local/hadoop/etc/hadoop/:/usr/local/pig/lib/:.:/usr/java/jdk1.8.0_45/jre/lib/rt.jar:/usr/java/jdk1.8.0_45/lib/dt.jar:/usr/java/jdk1.8.0_45/lib/tools.jar:/usr/share/ant/lib/ant-launcher.jar

并且这两个环境变量设置如下:

export PIG_INSTALL=/usr/local/pig
export PIG_CLASSPATH=$HADOOP_INSTALL/etc/hadoop

文件IsUseragentBot.java的源代码如下所示:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import org.apache.pig.FilterFunc;
import org.apache.pig.data.Tuple;

public class IsUseragentBot extends FilterFunc {

    private Set<String> blacklist = null;

    private void loadBlacklist() throws IOException {
        blacklist = new HashSet<String>();
        BufferedReader in = new BufferedReader(new FileReader("blacklist"));
        String userAgent = null;
        while ((userAgent = in.readLine()) != null) {
            blacklist.add(userAgent);
        }
    }

    @Override
    public Boolean exec(Tuple tuple) throws IOException {
        if (blacklist == null) {
            loadBlacklist();
        }
        if (tuple == null || tuple.size() == 0) {
            return null;
        }

        String ua = (String)tuple.get(0);
        if (blacklist.contains(ua)) {
            return true;
        }
        return false;   
    }

}

虽然我要通过执行javac IsUseragentBot.java来编译源文件,但它总是失败并且说&#34;错误包org.apache.pig不存在&#34;,任何伙伴都可以帮助我,谢谢很多!

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题,它与猪和hadoop之间的兼容性有关,除了猪的编译