我用的Hadoop流的tcsh中执行一个脚本文件:
-- First copy the jar files to the Hadoop filesystem,
so that they are next to inputdir and outputdir. --
cp App/* /hadoop/jardir/
-- Run Hadoop --
hadoop jar /usr/lib/hadoop/contrib/streaming/hadoop-streaming-0.20.2-cdh3u4.jar \\
-D mapred.task.timeout=120000000 \\
-input "/hadoop/inputdir/" -output "/hadoop/outputdir/" \\
-mapper script.sh -reducer script.sh -file script.sh \\
-jobconf mapred.map.tasks=1 -jobconf mapred.reduce.tasks=0 >>& log.txt
该脚本文件调用Java的是这样的:
java -cp /hadoop/jardir/SomeJavaApp.jar:/hadoop/jardir/* some.JavaApplication
即使我明确地告诉Java的类路径,运行它失败:
Exception in thread "main" java.lang.NoClassDefFoundError: some/JavaApplication
Caused by: java.lang.ClassNotFoundException: some.JavaApplication
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: some.JavaApplication. Program will exit.
我已经尝试过,如设置Hadoops各种建议-libjars
参数,但这并没有帮助。
我如何使用Hadoop流运行时通过脚本的Java应用程序?