【问题标题】:Unable to run Pig jar using java command无法使用 java 命令运行 Pig jar
【发布时间】:2015-12-02 13:17:32
【问题描述】:

我正在尝试简单的猪代码,但它给了我一些权限。 这是我的示例猪代码

import java.io.IOException;
import org.apache.pig.PigServer;
import org.apache.pig.ExecType;
import org.apache.hadoop.conf.Configuration;
public class PigTest{
   public static void main(String[] args) {
   try {
        Configuration conf = new Configuration();
        conf.set("hdp.version","2.3.0.0-2557");
        //PigServer pigServer = new PigServer("mapreduce",conf);
        PigServer pigServer = new PigServer(ExecType.MAPREDUCE, conf);
     runIdQuery(pigServer, "myfile.txt");
   }
   catch(Exception e) {
   }
}
public static void runIdQuery(PigServer pigServer, String inputFile) throws IOException {
   pigServer.registerQuery("A = load '" + inputFile + "' using PigStorage(':');");
   pigServer.registerQuery("B = foreach A generate $0 as id;");
   pigServer.store("B", "idout");
   }
}

我将我的类路径设置如下

echo $CLASSPATH
.:/usr/hdp/2.3.0.0-2557/hadoop/client/*:/usr/hdp/2.3.0.0-2557/hadoop-hdfs/lib/*:/usr/hdp/2.3.0.0-2557/hadoop-mapreduce/lib/*:/usr/hdp/2.3.0.0-2557/hadoop-yarn/lib/*:/usr/hdp/2.3.0.0-2557/pig/lib/*:/usr/hdp/2.3.0.0-2557/hadoop/conf:/usr/hdp/2.3.0.0-2557/pig/pig-0.15.0.2.3.0.0-2557-core-h2.jar

当我使用 java 命令运行我的代码时,它运行良好,但是当我创建了我的代码的 jar 并尝试运行时,它给了我以下权限错误。

 ****java -cp /usr/hdp/2.3.0.0-2557/hadoop/client/*;/usr/hdp/2.3.0.0-2557/hadoop-hdfs/lib/*;/usr/hdp/2.3.0.0-2557/hadoop-mapreduce/lib/*;/usr/hdp/2.3.0.0-2557/hadoop-yarn/lib/*;/usr/hdp/2.3.0.0-2557/pig/lib/*;/usr/hdp/2.3.0.0-2557/hadoop/conf;/usr/hdp/2.3.0.0-2557/pig/pig-0.15.0.2.3.0.0-2557-core-h2.jar -jar PigTest.jar****


Error: Could not find or load main class .usr.hdp.2.3.0.0-2557.hadoop.client.activation.jar
-bash: /usr/hdp/2.3.0.0-2557/hadoop-hdfs/lib/asm-3.2.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/hadoop-mapreduce/lib/aopalliance-1.0.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/hadoop-yarn/lib/activation-1.1.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/pig/lib/accumulo-core-1.5.0.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/hadoop/conf: is a directory
-bash: /usr/hdp/2.3.0.0-2557/pig/pig-0.15.0.2.3.0.0-2557-core-h2.jar: Permission denied

我该如何解决这个问题?

【问题讨论】:

    标签: java linux hadoop apache-pig


    【解决方案1】:

    试试下面的

    1. 使用/usr/hdp/2.3.0.0-2557/hadoop/client/*.jar 代替/usr/hdp/2.3.0.0-2557/hadoop/client/*(请参阅最后的.jar。将所有* 替换为*.jar)
    2. 尝试使用冒号 (:) 代替分号 (;)。 Linux 上使用冒号分隔路径
    3. 如果上述步骤 1 不起作用,请尝试将单个 JAR 放入路径中,而不是 *.jar

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多