JavaNIFI自定义orc处理器为类org提供NoClassDefFoundError。阿帕奇。hadoop。hdfs。分布式文件系统
我正在尝试用ApacheNIFI开发一个定制处理器,它直接将orc文件写入远程hadoop集群。为了编写它们,我使用了orc core api。我试着在本地FS上写这些文件,它们还可以:hive是它们的“最终目的地”,读取它们没有问题
问题是,在尝试创建Writer对象时,我得到了类org的NoClassDefFoundError。阿帕奇。hadoop。hdfs。分布式文件系统
这就是使用的代码:
Configuration conf = new Configuration();
conf.addResource(new Path(hadoopConfigurationPath+"/core-site.xml"));
conf.addResource(new Path(hadoopConfigurationPath+"/hdfs-site.xml"));
conf.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
String hdfsUri = conf.get("fs.default.name");
...
try{
writer = OrcFile.createWriter(new Path(hdfsUri+"/"+filename+".orc"), OrcFile.writerOptions(conf).setSchema(orcSchema));
}
catch(IOException e){
log.error("Cannot open hdfs file. Reason: "+e.getMessage());
session.transfer(flowfile, hdfsFailure);
return;
}
...
我复制了lib目录中的hadoop hdfsjar,并尝试使用ClassLoader查看类路径中加载的jar的运行时,可以看到它。将它们包含在maven依赖项中也不能解决这个问题
任何关于如何消除这一错误的建议都非常感谢。谢谢大家!
# 1 楼答案
@riccamini
请试着这样做,这肯定是工作
只需在处理器pom文件中添加以下与hadoop版本相关的依赖项
你仍然无法解决错误。最后将hadoop hdfs jar复制到NiFi\lib目录中
如果对你有用,请告诉我