我试图使用nifi作为flink中的源连接器,得到以下错误。我的nifi服务处于运行状态,模板处于运行状态。
flink错误:
信息:源:自定义源(2/2)(e9ceb92d895d6cd6524ecd0615b219df)从运行切换到失败。java.lang.noclassdeffounderror:org/apache/commons/logging/logfactory位于org.apache.http.conn.ssl.defaulthostnameverifier.(defaulthostnameverifier)。java:82)在org.apache.http.impl.client.httpclientbuilder.build(httpclientbuilder。java:966)位于org.apache.nifi.remote.util.sitetositerestapiclient.setupclient(sitetositerestapiclient)。java:283)在org.apache.nifi.remote.util.sitetositerestapiclient.gethttpclient(sitetositerestapiclient。java:219)在org.apache.nifi.remote.util.sitetositerestapiclient.execute(sitetositerestapiclient。java:1189)在org.apache.nifi.remote.util.sitetositerestapiclient.execute(sitetositerestapiclient。java:1237)在org.apache.nifi.remote.util.sitetositerestapiclient.fetchcontroller(sitetositerestapiclient。java:419)位于org.apache.nifi.remote.util.sitetositerestapiclient.getcontroller(sitetositerestapiclient)。java:394)位于org.apache.nifi.remote.util.sitetositerestapiclient.getcontroller(sitetositerestapiclient)。java:361)在org.apache.nifi.remote.client.siteinfoprovider.refreshremoteinfo(siteinfoprovider。java:69)位于org.apache.nifi.remote.client.siteinfoprovider.getportidentifier(siteinfoprovider.com)。java:220)位于org.apache.nifi.remote.client.siteinfoprovider.getoutputportidentifier(siteinfoprovider)。java:204)在org.apache.nifi.remote.client.socket.socketclient.getportidentifier(socketclient。java:79)在org.apache.nifi.remote.client.socket.socketclient.createtransaction(socketclient。java:121)在org.apache.flink.streaming.connectors.nifi.nifisource.run(nifisource。java:89)在org.apache.flink.streaming.api.operators.streamsource.run(streamsource。java:100) 在org.apache.flink.streaming.api.operators.streamsource.run(streamsource。java:63)位于org.apache.flink.streaming.runtime.tasks.sourcestreamtask$legacysourcefunctionthread.run(sourcestreamtask)。java:196)
public class NiFiSourceTopologyExample {
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder()
.url("http://localhost:8080/nifi")
.portName("CasandraOut")
.requestBatchCount(5)
.buildConfig();
try{
SourceFunction<NiFiDataPacket> nifiSource = new NiFiSource(clientConfig);
DataStream<NiFiDataPacket> streamSource = env.addSource(nifiSource).setParallelism(2);
DataStream<String> dataStream = streamSource.map(new MapFunction<NiFiDataPacket, String>() {
@Override
public String map(NiFiDataPacket value) throws Exception {
return new String(value.getContent(), Charset.defaultCharset());
}
});
dataStream.print();
env.execute();
}catch(Exception e)
{
System.out.println("Error->"+e.getMessage());
}
}
}
1条答案
按热度按时间aiqt4smr1#
错误
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
意味着您直接或间接地使用apachecommons日志库。异常noclassdeffounderror可能是由于某些类路径问题造成的,但这通常是由于类路径中缺少jar造成的。
尝试添加
commons-logging-x.jar
转换为项目依赖项,然后重试。