知识点
相关文章
更多最近更新
更多Hadoop 中的 ClassNotFoundException
2019-03-28 13:40|来源: 网络
在执行hbase或mapreduce的程序时,有时会遇到ClassNotFoundException。如果jar包里的MANIFEST.MF没有指定Main-Class,就会遇到这一问题。但如果指定无误,还是会遇到这样的问题。
有人的建议是将所有用到的jar包都打进要执行的jar包里。这是一种解决方法。但即使将jar包全打进了新的jar文件,还是会遇到该问题。如我在执行hbase的IndexBuilder这个例子时,遇到如下问题:
12/06/11 18:23:32 INFO mapred.JobClient: Task Id : attempt_201206111811_0001_m_000002_1, Status : FAILED java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.Hadoop.hbase.mapreduce.MultiTableOutputFormat at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:867) at org.apache.hadoop.mapreduce.JobContext.getOutputFormatClass(JobContext.java:235) at org.apache.hadoop.mapred.Task.initialize(Task.java:513) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:353) at org.apache.hadoop.mapred.Child$4.run(Child.java:255) 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:1121) at org.apache.hadoop.mapred.Child.main(Child.java:249) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.mapreduce.MultiTableOutputFormat 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:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:820) at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:865) ... 8 more
org.apache.hadoop.hbase.mapreduce.MultiTableOutputFormat是包含在hbase-0.94.0.jar里的。我打的jar包里确认有该jar文件,还是找不到。http://wiki.apache.org/hadoop/Hbase/MapReduce 和http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/package-summary.html 的HBase, MapReduce and the CLASSPATH
中提到,MapReduce的Job部署到群集中,并不缺省就能访问hbase配置目录和HBase下的类。解决办法:
1. 将hbase下的配置文件hbase-site.xml拷贝到hadoop的conf目录下,将hbase下的lib文件,拷贝到hadoop下的lib文件。并将变动应用到集群的每一台机器。
2. 编辑$HADOOP_HOME/conf下的hadoop-env.sh文件,将相关文件和目录加到HADOOP_CLASSPATH中。但这有一个问题,就是会污染hadoop的执行环境。如果不在意的话,倒是可以这么用。但可能会有较大副作用。尤其是当环境出问题的时候。
HADOOP_CLASSPATH=${HBASE_HOME}/hbase-0.94.0.jar:`${HBASE_HOME}/bin/hbase classpath`
注意将hbase-0.94.jar放在其他库的前面。
3.在hbase 0.90版以后,可以只在本地环境修改CLASSPATH变量,不会对其他环境产生不良影响。
[www.linuxidc.com@Hadoop48 ~]$ HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar multitb.jar cars.csv
相关问答
更多-
Exporter-atlas2.1不仅仅是jar的名称(因为它被设置为finalName),当你解压缩时,你将这个目录作为解压缩依赖项的父目录?
false in the assemly configurator resolved the issue. -
运行hadoop示例作业会导致ClassNotFoundException(Running hadoop example jobs result in ClassNotFoundException)[2023-08-03]
Commmand Line变得乱码(-Xmx选项)。 它 The Commmand Line was getting garbled (-Xmx options). It -
我相信你不应该在classname中包含“ .class ”。 代替 job.setJarByClass(hadoopshingles.Saishingles.class); 它应该是 job.setJarByClass(hadoopshingles.Saishingles); I believe you should not be including ".class" in the classname. Instead of job.setJarByClass(hadoopshingles.Saishin ...
-
分析Hadoop(Profiling Hadoop)[2022-02-05]
Hadoop有asm 3.2而我使用的是ASM 5.在ASM5中,ClassVisitor是一个超类,而在3.2中它是一个接口。 出于某种原因,错误是Throwable(信任Shevek),catch块只捕获异常。 任何hadoop日志都没有捕获throwable错误。 因此,调试非常困难。 使用jar jar链接修复asm版本问题,现在一切正常。 如果你正在使用Hadoop并且某些东西不起作用并且没有日志显示任何错误,那么请尝试抓住Throwable。 阿伦 Hadoop had asm 3.2 and ... -
带有已导入的类的Hadoop ClassNotFoundException(Hadoop ClassNotFoundException with class that's imported anymore)[2022-12-16]
我已经通过从代码内部一直到编译它来改变我的hadoop作业的类名来解决这个问题。 我仍然不知道为什么。 I've solved this by changing the class' name of my hadoop jobs all the way from inside the code up to when compiling it. I still have no idea why though. -
您应该添加/usr/lib/hadoop-0.xx/lib找到的所有jar以避免这种类路径问题。 为了给你一个想法,你可以输入hadoop classpath ,它将打印出获取Hadoop jar和所需库所需的类路径。 在你的情况下,你错过了hadoop-common-0.xx.jar ,所以你应该把它添加到classpath中,你应该很好。 You should add all the jars found in /usr/lib/hadoop-0.xx/lib to avoid this kind of ...
-
罐子已经搞乱了。 如果您的类属于默认包,它们不应位于example/titanic/目录下,而应位于根目录下。 The jar has is messed up. If your classes belong to the default package, they should not be located under example/titanic/ directories but rather under root directory.
-
缺少包含org.apache.hadoop.hbase.mapreduce.TableOutputFormat Jar 下载jar并设置你的classpath This was my question. I fixed this using libjars option with Hadoop. export libpath=/path to hbase jar hadoop jar myjarname.jar
arguments -libjar ${libpath} -
运行Kafka hadoop-consumer时出现ClassNotFoundException(ClassNotFoundException while running Kafka hadoop-consumer)[2022-08-06]
你缺少类org.apache.hadoop.conf.Configuration的 jar,它不是 Kafka库的一部分。 它应该包含在hadoop-common-2.5.0中 。 您必须将此jar添加到类路径中。 You are missing jar with the class org.apache.hadoop.conf.Configuration which is not part of the Kafka library. It should be included in hadoop-comm ... -
尝试运行SparkPi示例时ClassNotFoundException(ClassNotFoundException when trying run the SparkPi example)[2022-09-06]
您需要指定示例类的名称,而不是源文件的路径; 尝试 ./bin/run-example SparkPi 10 Spark文档的“ 运行示例和Shell”部分对此进行了描述。 You need to specify the name of the example class, not the path to a source file; try ./bin/run-example SparkPi 10 This is described in the Running the Examples and Sh ...