mapreduce使用scala错误:java.lang.classnotfoundexception:scala.predef$

b4lqfgs4  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(377)

我试图通过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库添加到了我的类路径中,但是我得到了上面的错误。
hadoop版本:hadoop 2.7.1.2.3.0.0-255 scala版本:2.11.8 java版本1.7.0\u 85
任何建议都将不胜感激。

5uzkadbs

5uzkadbs1#

除了将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

相关问题