当我从https://github.com/ibm-messaging/message-hub-samples运行Kafka本机Message Hub示例代码时,我得到以下异常:
Exception in thread "main" org.apache.kafka.common.KafkaException: Failed to construct kafka producer
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:320)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:180)
at com.example.ProducerRunnable.<init>(ProducerRunnable.java:44)
at com.example.KafkaNativeSample.createMessageProducer(KafkaNativeSample.java:113)
at com.example.KafkaNativeSample.main(KafkaNativeSample.java:65)
Caused by: org.apache.kafka.common.KafkaException: org.apache.kafka.common.KafkaException: java.io.FileNotFoundException:
at org.apache.kafka.common.network.SSLChannelBuilder.configure(SSLChannelBuilder.java:45)
at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:49)
at org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils.java:79)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:270)
... 4 more
Caused by: org.apache.kafka.common.KafkaException: java.io.FileNotFoundException:
at org.apache.kafka.common.security.ssl.SSLFactory.configure(SSLFactory.java:99)
at org.apache.kafka.common.network.SSLChannelBuilder.configure(SSLChannelBuilder.java:41)
... 7 more
Caused by: java.io.FileNotFoundException:
at java.io.FileInputStream.<init>(FileInputStream.java:156)
at java.io.FileInputStream.<init>(FileInputStream.java:111)
at org.apache.kafka.common.security.ssl.SSLFactory$SecurityStore.load(SSLFactory.java:201)
at org.apache.kafka.common.security.ssl.SSLFactory$SecurityStore.access$000(SSLFactory.java:186)
at org.apache.kafka.common.security.ssl.SSLFactory.createSSLContext(SSLFactory.java:123)
at org.apache.kafka.common.security.ssl.SSLFactory.configure(SSLFactory.java:97)
... 8 more
缺少什么文件?
答案 0 :(得分:3)
需要编辑示例resources/consumer.properties
和resources/producer.properties
文件以指定JRE证书颁发机构商店的位置及其密码。
例如,使用默认的JRE存储:
ssl.truststore.location=C:\\Java80\\jre\\lib\\security\\cacerts
ssl.truststore.password=changeit