【问题标题】:how to solve "Error during parsing. could not instantiate" in pig?如何解决pig中的“解析时出错。无法实例化”?
【发布时间】:2013-06-15 14:22:28
【问题描述】:

大家好,我是 Pig 的新手,我正在尝试使用 pig 脚本:

然后它显示以下错误: ERROR 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);


          }}
}

【问题讨论】:

  • 你能粘贴/home/training/pig_1371303109105.log吗?
  • 你好 zsxwing thanxx 重播我的问题我无法在这里发布我的全部内容所以我把它放在粘贴箱你能在那里看到它并告诉我为什么这个错误出现在我的代码中请..pastebin.com/zrdRkSkg

标签: hadoop apache-pig


【解决方案1】:

我从您的错误日志中发现了以下信息:

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 脚本的?这个类应该在 Pig 环境中。 org.apache.commons.logging.Logcommons-logging-*.*.*.jar

【讨论】:

  • 我正在使用 Cloudera 进行培训,先生
  • 所以你使用它的网页界面来运行 Pig 脚本?
  • 不,先生,我正在终端上运行它,并在本地模式下运行 grunt shell。
  • 先生,我必须注册我在 udf 代码中使用的所有 jar,例如 pig jar 和 commons
  • 我发现我的问题的解决方案是我必须在 Eclipse 的项目工作区中添加一个所有 jar 文件,其中包括用于 pig、commons-lang3-3.1、commons-logging-1.1 的所有 jar .3.jar 仅此而已,我搜索了很多次但没有得到我的答案我从一开始就做所有事情并得到我的答案谢谢zsxwing给我时间回答我的问题你的回答真的对我有很大帮助..谢谢全部
猜你喜欢
  • 2020-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-28
  • 2018-05-21
  • 1970-01-01
  • 2019-08-17
相关资源
最近更新 更多