错误包 org.apache.pig.FilterFunc 不存在
Posted
技术标签:
【中文标题】错误包 org.apache.pig.FilterFunc 不存在【英文标题】:error package org.apache.pig.FilterFunc not exist 【发布时间】:2015-12-15 08:26:06 【问题描述】:请问一个问题,我安装并配置了 Pig,但是当我尝试使用 javac 命令编译一个非常简单的 java 源文件时,它显示“error package org.apache.pig.FilterFunc not exist
”。
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来编译源文件,但它总是失败并说“错误包org.apache.pig不存在”,请任何伙伴帮助我,非常感谢!
【问题讨论】:
【参考方案1】:这个问题我已经解决了,除了pig的编译之外,和pig和hadoop的兼容性有关
【讨论】:
以上是关于错误包 org.apache.pig.FilterFunc 不存在的主要内容,如果未能解决你的问题,请参考以下文章
Python 'No module named' 错误; “包”不是包