尝试用java启动pig脚本时出错

w80xi6nr  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(331)

我正在尝试从java启动一个pig脚本。这是我的密码:

import java.io.IOException;
import java.util.Properties;
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.backend.executionengine.ExecException;

public class pigCV {

public static void main(String args[]){

    PigServer pigServer;
    try {

        Properties props = new Properties();
        props.setProperty("fs.default.name", "hdfs://hdfs://localhost:8022");
        props.setProperty("mapred.job.tracker", "localhost:8021");

        pigServer = new PigServer(ExecType.MAPREDUCE, props);

        pigServer.registerScript("Desktop/text_v3.pig");

    } 
    catch (ExecException e) {   e.printStackTrace(); } 
    catch (IOException e) { e.printStackTrace(); }

}

}

但会引发一些异常:
2013-05-23 01:34:54,666错误[main]conf.configuration(1151):未能为解析器org.apache.xerces.jaxp设置setxincludeaware(true)。documentbuilderfactoryimpl@1787038:java.lang.unsupportedoperationexception:此分析器不支持规范“null”版本“null”java.lang.unsupportedoperationexception:此分析器不支持规范“null”javax.xml.parsers.documentbuilderfactory.setxincludeaware(documentbuilderfactory)中的版本“null”。java:590)在org.apache.hadoop.conf.configuration.loadresource(配置。java:1149)在org.apache.hadoop.conf.configuration.loadresources(配置。java:1125)在org.apache.hadoop.conf.configuration.getprops(配置。java:1064)在org.apache.hadoop.conf.configuration.get(配置。java:424)在org.apache.hadoop.mapred.jobconf.checkandwarndeprecation(jobconf。java:1709)在org.apache.hadoop.mapred.jobconf.(jobconf。java:164)位于org.apache.pig.backend.hadoop.executionengine.hexecutionengine.init(hexecutionengine。java:169)在org.apache.pig.backend.hadoop.executionengine.hexecutionengine.init(hexecutionengine)。java:137)在org.apache.pig.impl.pigcontext.connect(pigcontext。java:200)在org.apache.pig.pigserver.(pigserver。java:169)在org.apache.pig.pigserver.(pigserver。java:158)在org.apache.pig.pigserver.(pigserver。java:154)在pigcv.main(pigcv。java:21)
你有什么办法帮我吗?
谢谢您。

elcex8rz

elcex8rz1#

你可能有一个 Xerces 类路径中的实现。尝试设置

-Djavax.xml.parsers.DocumentBuilderFactory=
   com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

(在eclipse:vm参数中)或在代码中:

System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
  "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");

备注:
可能是拼写错误 fs.default.name :不应该吗 hdfs://localhost:8022 而不是 hdfs://hdfs://localhost:8022 ?

相关问题