使用Scala的Mapreduce错误:java.lang.ClassNotFoundException: Scala



我尝试通过scala实现一个简单的mapreduce作业。但是,当我使用命令

运行包时,
hadoop jar hadoop.jar mapreduce.MaxTemperature hdfs://sandbox/user/ajay/input hdfs://sandbox/user/ajay/output

我得到错误,

16/09/06 16:06:12 INFO mapreduce.Job: Task Id : attempt_1473177830264_0002_m_000001_2, Status : FAILED Error: java.lang.ClassNotFoundException: scala.Predef$
        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)
        at mapreduce.MaxTemperatureMapper.map(MaxTemperatureMapper.scala:17)
        at mapreduce.MaxTemperatureMapper.map(MaxTemperatureMapper.scala:9)
        at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:146)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:415)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

尽管我已经将scala-library添加到我的类路径中,我还是得到了上面的错误。

hadoop version: hadoop 2.7.1.2.3.0.0-255Scala版本:2.11.8Java版本1.7.0_85

除了将scala库添加到客户端的类路径之外,还必须将其添加到执行任务的所有节点中。这可以使用ToolRunner hadoop jar scala-2.11/hadoop_2.11-0.1.0.jar mapreduce.WordCount -libjars /usr/lib/scala-2.11.8/lib/scala-library.jar

实现。

相关内容

  • 没有找到相关文章

最新更新