如何解决“解析时出错。无法实例化”猪?

时间:2013-06-15 14:22:28

标签: hadoop apache-pig

大家好,我是Pig的新手,我正在尝试关注猪脚本:

然后它显示以下错误: 错误1000:解析期间出错。无法在日志文件中使用参数'null'详细信息实例化'UPER':/home/training/pig_1371303109105.log

我的猪脚本:

register udf.jar; 
A = LOAD 'data1.txt' USING PigStorage(',') AS (name:chararray, class:chararray, age:int);
B = foreach A generate UPER(class);

我按照this教程。

我的java类是:

enter code here


import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
import java.io.*;

public class UPER extends EvalFunc<String>{

    @Override
    public String exec(Tuple input) throws IOException {
        // TODO Auto-generated method stub
        if(input == null ||input.size() ==0)
         return null;
         try
         {
            String str=(String)input.get(0); 
            return str.toUpperCase(); 
         }
          catch(Exception e){
              throw new IOException("Caught exception processing input row ", e);


          }}
}

1 个答案:

答案 0 :(得分:2)

我从错误日志中找到了以下信息:

Caused by: java.lang.Error: Unresolved compilation problem:
        The type org.apache.commons.logging.Log cannot be resolved. It is indirectly referenced from required .class files

        at UPER.<init>(UPER.java:1)

我想org.apache.commons.logging.Log不在您的环境中。你是如何运行你的猪脚本的?这个班级应该在Pig环境中。 org.apache.commons.logging.Log位于commons-logging-*.*.*.jar