Elephant Bird Pig TypeRef ClassNotFoundException

Posted

技术标签:

【中文标题】Elephant Bird Pig TypeRef ClassNotFoundException【英文标题】: 【发布时间】:2013-09-17 10:47:12 【问题描述】:

我正在尝试使用大象鸟 4.1 将协议缓冲区中编码的数据处理为其猪表示。相关猪代码:

REGISTER '/home/ubuntu/elephant-bird/core/target/elephant-bird-core-4.1-SNAPSHOT.jar';
REGISTER '/home/ubuntu/elephant-bird/pig/target/elephant-bird-pig-4.1-SNAPSHOT.jar';
REGISTER '/home/ubuntu/elephant-bird/hadoop-compat/target/elephant-bird-hadoop-compat-4.1-SNAPSHOT.jar';

REGISTER '/home/ubuntu/libraryContainingProto.jar';

DEFINE ProtobufBytesToTuple com.twitter.elephantbird.pig.piggybank.ProtobufBytesToTuple('com.my.converted.proto.class');

raw_protobuffer = LOAD 'hbase://table' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('cf:cl') AS (downloader:chararray);
parsed = FOREACH raw_protobuffer GENERATE ProtobufBytesToTuple($0);

每当我尝试进行转换时,它都会因以下堆栈跟踪而惨遭失败:

Caused by: java.lang.RuntimeException: could not instantiate 'com.twitter.elephantbird.pig.piggybank.ProtobufBytesToTuple' with arguments '[com.my.converted.proto.class]'
    at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:618)
    at org.apache.pig.newplan.logical.expression.UserFuncExpression.getFieldSchema(UserFuncExpression.java:193)
    at org.apache.pig.newplan.logical.optimizer.FieldSchemaResetter.execute(SchemaResetter.java:264)
    at org.apache.pig.newplan.logical.expression.AllSameExpressionVisitor.visit(AllSameExpressionVisitor.java:143)
    at org.apache.pig.newplan.logical.expression.UserFuncExpression.accept(UserFuncExpression.java:88)
    at org.apache.pig.newplan.ReverseDependencyOrderWalker.walk(ReverseDependencyOrderWalker.java:70)
    at org.apache.pig.newplan.PlanVisitor.visit(PlanVisitor.java:52)
    at org.apache.pig.newplan.logical.optimizer.SchemaResetter.visitAll(SchemaResetter.java:67)
    at org.apache.pig.newplan.logical.optimizer.SchemaResetter.visit(SchemaResetter.java:122)
    at org.apache.pig.newplan.logical.relational.LOGenerate.accept(LOGenerate.java:246)
    at org.apache.pig.newplan.DependencyOrderWalker.walk(DependencyOrderWalker.java:75)
    at org.apache.pig.newplan.logical.optimizer.SchemaResetter.visit(SchemaResetter.java:114)
    at org.apache.pig.newplan.logical.relational.LOForEach.accept(LOForEach.java:76)
    at org.apache.pig.newplan.DependencyOrderWalker.walk(DependencyOrderWalker.java:75)
    at org.apache.pig.newplan.PlanVisitor.visit(PlanVisitor.java:52)
    at org.apache.pig.parser.LogicalPlanBuilder.expandAndResetVisitor(LogicalPlanBuilder.java:392)
    at org.apache.pig.parser.LogicalPlanBuilder.buildForeachOp(LogicalPlanBuilder.java:924)
    at org.apache.pig.parser.LogicalPlanGenerator.foreach_clause(LogicalPlanGenerator.java:14195)
"~/pig_1379411496557.log" [readonly] 396L, 30186C                                                                 13,1-8        Top
    at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:618)
    at org.apache.pig.newplan.logical.expression.UserFuncExpression.getFieldSchema(UserFuncExpression.java:193)
    at org.apache.pig.newplan.logical.optimizer.FieldSchemaResetter.execute(SchemaResetter.java:264)
    at org.apache.pig.newplan.logical.expression.AllSameExpressionVisitor.visit(AllSameExpressionVisitor.java:143)
    at org.apache.pig.newplan.logical.expression.UserFuncExpression.accept(UserFuncExpression.java:88)
    at org.apache.pig.newplan.ReverseDependencyOrderWalker.walk(ReverseDependencyOrderWalker.java:70)
    at org.apache.pig.newplan.PlanVisitor.visit(PlanVisitor.java:52)
    at org.apache.pig.newplan.logical.optimizer.SchemaResetter.visitAll(SchemaResetter.java:67)
    at org.apache.pig.newplan.logical.optimizer.SchemaResetter.visit(SchemaResetter.java:122)
    at org.apache.pig.newplan.logical.relational.LOGenerate.accept(LOGenerate.java:246)
    at org.apache.pig.newplan.DependencyOrderWalker.walk(DependencyOrderWalker.java:75)
    at org.apache.pig.newplan.logical.optimizer.SchemaResetter.visit(SchemaResetter.java:114)
    at org.apache.pig.newplan.logical.relational.LOForEach.accept(LOForEach.java:76)
    at org.apache.pig.newplan.DependencyOrderWalker.walk(DependencyOrderWalker.java:75)
    at org.apache.pig.newplan.PlanVisitor.visit(PlanVisitor.java:52)
    at org.apache.pig.parser.LogicalPlanBuilder.expandAndResetVisitor(LogicalPlanBuilder.java:392)
    at org.apache.pig.parser.LogicalPlanBuilder.buildForeachOp(LogicalPlanBuilder.java:924)
    at org.apache.pig.parser.LogicalPlanGenerator.foreach_clause(LogicalPlanGenerator.java:14195)
    at org.apache.pig.parser.LogicalPlanGenerator.op_clause(LogicalPlanGenerator.java:1623)
    at org.apache.pig.parser.LogicalPlanGenerator.general_statement(LogicalPlanGenerator.java:799)
    at org.apache.pig.parser.LogicalPlanGenerator.statement(LogicalPlanGenerator.java:517)
    at org.apache.pig.parser.LogicalPlanGenerator.query(LogicalPlanGenerator.java:392)
    at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:184)
    ... 15 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:586)
    ... 37 more
Caused by: java.lang.NoClassDefFoundError: com/twitter/elephantbird/util/TypeRef
    at com.twitter.elephantbird.pig.piggybank.ProtobufBytesToTuple.<init>(ProtobufBytesToTuple.java:37)
    ... 42 more
Caused by: java.lang.ClassNotFoundException: com.twitter.elephantbird.util.TypeRef
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 43 more

我怀疑这可能与包含适当的罐子有关,据我所知,这些依赖项应该在大象鸟核心中。

【问题讨论】:

【参考方案1】:

当我排除 'elephant-bird-core' 库后,我能够重现相同的错误。所以我怀疑jar有问题。

您可以通过以下命令检查jar是否有TypeRef.class

jar -xvf elephant-bird-core-4.1-SNAPSHOT.jar | grep "TypeRef.class"

【讨论】:

感谢您的提示。罐子很好,我按照您的建议进行了检查。【参考方案2】:

最后归结为这样一个事实,即简单地使用 grunt 中的 REGISTER 不会为集群上的计算提供库。

为了让它们正常工作,我必须(在我的情况下)将大象鸟猪、大象鸟核心和大象鸟-hadoop-compat 放到 /usr/lib/hadoop 目录中。

【讨论】:

以上是关于Elephant Bird Pig TypeRef ClassNotFoundException的主要内容,如果未能解决你的问题,请参考以下文章

Pig Job 使用 Elephant Bird jsonLoader 时挂起

PIG 中 Elephant-Bird UDF 中的 JSON 数组字段处理

无法使用 Pig 中的 Elephant Bird 访问带有包和元组的嵌套 JSON

Pig Elephant-Bird 找到接口 org.apache.hadoop.mapreduce.JobContext,但是应该有类

象鸟构建失败

从 HDFS 加载数据不适用于 Elephantbird