我解决了这个问题。我设置的任何类路径都可能被 hadoop 可执行文件覆盖。所以我不得不在调用 java 命令的地方修改 hadoop 可执行文件,并在我的 hadoop jar 的类路径中添加一个 -cp 标志,如下所示:
exec "$JAVA" -cp "$CLASSPATH:/usr/local/Cellar/hadoop/2.4.1/libexec/share/hadoop/common/ :/usr/local/Cellar/hadoop/2.4.1/libexec/share/ hadoop/common/lib/ : /usr/local/Cellar/hadoop/2.4.1/libexec/share/hadoop/hdfs/:/usr/local/Cellar/hadoop/2.4.1/libexec/share/hadoop/ hdfs/ lib/ :/usr/local/Cellar/hadoop/2.4.1/libexec/share/hadoop/mapreduce/ :/usr/local/Cellar/hadoop/2.4.1/libexec/share/hadoop/mapreduce/lib/ :/ usr/local/Cellar/hadoop/2.4.1/libexec/share/hadoop/tools/ : /usr/local/Cellar/hadoop/2.4.1/libexec/share/hadoop/tools/lib/ :/usr/local/ Cellar/hadoop/2.4.1/libexec/share/hadoop/yarn/ :/usr/local/Cellar/hadoop/2.4.1/libexec/share/hadoop/yarn/lib/ " $JAVA_HEAP_MAX $HADOOP_OPTS $CLASS "$@ "