我只是按照教程运行了一个示例程序:
http://web.stanford.edu/class/cs246/homeworks/tutorial.pdf

并得到以下错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
16/10/24 21:48:18 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/htrace/core/Tracer$Builder
    at org.apache.hadoop.fs.FsTracer.get(FsTracer.java:42)
    at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2630)
    at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:93)
    at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2680)
    at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2662)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:379)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:178)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:363)
    at org.apache.hadoop.fs.Path.getFileSystem(Path.java:296)
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.addInputPath(FileInputFormat.java:520)
    at edu.stanford.cs246.wordcount.WordCount.run(WordCount.java:43)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at edu.stanford.cs246.wordcount.WordCount.main(WordCount.java:24)
Caused by: java.lang.ClassNotFoundException: org.apache.htrace.core.Tracer$Builder
    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:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 13 more

如何解决该问题,以便我可以编译程序?谢谢!

最佳答案

您只需要添加htrace jar文件。对我来说,hadoop-hdfs / libs中的htrace-core4-4.0.1-incubating.jar起作用。谢谢

08-28 05:07