gpt4 book ai didi

apache-kafka - KafkaSpout 为 log4j 抛出 NoClassDefFoundError

转载 作者:行者123 更新时间:2023-12-04 17:17:30 25 4
gpt4 key购买 nike

出于某种原因,当我尝试在 Storm 集群上运行拓扑时出现以下错误:

java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.Log4jLoggerFactory
at org.apache.log4j.Logger.getLogger(Logger.java:39)
at kafka.utils.Logging$class.logger(Logging.scala:24)
at kafka.consumer.SimpleConsumer.logger$lzycompute(SimpleConsumer.scala:30)
at kafka.consumer.SimpleConsumer.logger(SimpleConsumer.scala:30)
at kafka.utils.Logging$class.info(Logging.scala:67)
at kafka.consumer.SimpleConsumer.info(SimpleConsumer.scala:30)
at kafka.consumer.SimpleConsumer.liftedTree1$1(SimpleConsumer.scala:75)
at kafka.consumer.SimpleConsumer.kafka$consumer$SimpleConsumer$$sendRequest(SimpleConsumer.scala:69)
at kafka.consumer.SimpleConsumer.getOffsetsBefore(SimpleConsumer.scala:128)
at kafka.javaapi.consumer.SimpleConsumer.getOffsetsBefore(SimpleConsumer.scala:79)
at storm.kafka.KafkaUtils.getOffset(KafkaUtils.java:77)
at storm.kafka.KafkaUtils.getOffset(KafkaUtils.java:67)
at storm.kafka.PartitionManager.<init>(PartitionManager.java:83)
at storm.kafka.ZkCoordinator.refresh(ZkCoordinator.java:98)
at storm.kafka.ZkCoordinator.getMyManagedPartitions(ZkCoordinator.java:69)
at storm.kafka.KafkaSpout.nextTuple(KafkaSpout.java:135)
at backtype.storm.daemon.executor$fn__3373$fn__3388$fn__3417.invoke(executor.clj:565)
at backtype.storm.util$async_loop$fn__464.invoke(util.clj:463) at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:745)cg

问题是什么以及如何解决?

以下是我包含的依赖项:
 <dependencies>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>0.9.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.2-beta</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-kafka</artifactId>
<version>0.9.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.11</version>
</dependency>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[3.0,)</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-stream</artifactId>
<version>[3.0,)</version>
</dependency>
</dependencies>

最佳答案

问题是您应该通过以下方式包含 Kafka:

   <dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.1.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>

出于以下原因:

Note that the ZooKeeper and log4j dependencies are excluded to prevent version conflicts with Storm's dependencies.

关于apache-kafka - KafkaSpout 为 log4j 抛出 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33054294/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com