[英]Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/hadoop/tracing/SpanReceiverHost
I am running Hadoop 2.8.1 and Hive 2.3.0 I am tring to read values from an a table created in Hive and the current exception is我正在运行 Hadoop 2.8.1 和 Hive 2.3.0 我正在尝试从在 Hive 中创建的表中读取值,当前异常是
java.lang.ClassNotFoundException: org.apache.hadoop.tracing.SpanReceiverHost
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
And here is the code that I have used to read the tables这是我用来阅读表格的代码
public static final String HIVEURL = "jdbc:hive2://localhost:10000";
public static final String DB_NAME = "default";
public static final String TABLE_NAME = "order_line";
public static void main(String[] args) throws Exception {
HiveConf hiveConf = new HiveConf();
//hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, HIVEURL);
HiveMetaStoreClient hiveClient = new HiveMetaStoreClient(hiveConf);
Job job =Job.getInstance();
TaskAttemptContext ctx = new TaskAttemptContextImpl(job.getConfiguration(), new TaskAttemptID());
HCatInputFormat hcif = HCatInputFormat.setInput(job, DB_NAME, TABLE_NAME);
HCatSchema allCols = hcif.getTableSchema(job.getConfiguration());
List<HCatFieldSchema> usedList = new ArrayList<>();
usedList.add(allCols.get(2)); // por ex...
HCatSchema someCols = new HCatSchema(usedList);
hcif.setOutputSchema(job, someCols);
for(InputSplit split: hcif.getSplits(job)) {
RecordReader<WritableComparable, HCatRecord> rr = hcif.createRecordReader(split,ctx);
rr.initialize(split, ctx);
while(rr.nextKeyValue()) {
HCatRecord record = rr.getCurrentValue();
// usar record.get(...) para obter a coluna...
//Object o = record.get(1);
//System.out.println(o.toString());
}
rr.close();
}
hiveClient.close();
}
And here it is the Pom file that I have used这是我使用的 Pom 文件
org.apache.hive.hcatalog hive-hcatalog-core 2.3.0 org.apache.hive.hcatalog hive-hcatalog 0.13.1-cdh5.3.5 org.apache.hive hive-common 2.3.0 org.apache.hive.hcatalog hive-hcatalog-core 2.3.0 org.apache.hive.hcatalog hive-hcatalog 0.13.1-cdh5.3.5 org.apache.hive hive-common 2.3.0
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive</artifactId>
<version>0.13.1-cdh5.3.5</version>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-metastore</artifactId>
<version>2.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-common -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-core -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>2.6.0-mr1-cdh5.12.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.9.3</version>
</dependency>
</dependencies>
I can't see what actually causes the loadClass
from the stack trace snippet, but it appears that the class doesn't actually exist in the version, 2.8.1, of hadoop-common
you're using.我无法从堆栈跟踪片段中看到实际导致loadClass
原因,但看起来该类实际上并不存在于您正在使用的hadoop-common
版本 2.8.1 中。 It seems to have vanished somewhere after 2.7.2它似乎在 2.7.2 之后的某个地方消失了
It, or something with the same name, is in the hbase source它或同名的东西在hbase 源中
Have you got a mix'n'match of versions going on?你有混合的版本吗?
<!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-common -->
<!-- org/apache/hadoop/tracing/SpanReceiverHost The Last version is hadoop-common 2.7.7-->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.7.7</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.