java.lang.ClassNotFoundException: kafka.api.Offset

2019-04-10 15:09发布

问题:

I am getting error java.lang.ClassNotFoundException kafka.api.OffsetRequest while trying integrate Kafka to our Storm topology. What versions you are running and it is working? My pom.xml

  <dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-core</artifactId>
        <version>0.9.2-incubating</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-kafka</artifactId>
        <version>0.9.2-incubating</version>
    </dependency>

回答1:

Finally I solved it by implementing my own Kafka SPOUT (reusing example code) with this dependencies:

    <dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-core</artifactId>
        <version>0.9.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.9.2</artifactId>
        <version>0.8.1.1</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>jmxri</artifactId>
                <groupId>com.sun.jmx</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jms</artifactId>
                <groupId>javax.jms</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jmxtools</artifactId>
                <groupId>com.sun.jdmk</groupId>
            </exclusion>
        </exclusions>
    </dependency>


回答2:

I can successfully use kafka.api.OffsetRequest with the following sample topology (KafkaSpoutTestTopology) in a Docker cluster: https://github.com/wurstmeister/storm-kafka-0.8-plus-test The topology uses storm-kafka version 0.9.3. Note: "fig" command is replaced with "docker-compose" command.

EarliestTime() and LatestTime() method work fine.