Home Spring Integration Kafka ClassNotFoundException: KafkaHeaderMapper
Reply: 1

Spring Integration Kafka ClassNotFoundException: KafkaHeaderMapper

user1575148
1#
user1575148 Published in 2017-12-07 22:15:55Z

While running a Spring Boot application with spring-integration-kafka library, I am getting the following error:

Caused by: java.lang.ClassNotFoundException: org.springframework.kafka.support.KafkaHeaderMapper

The exception is thrown at the first line in the body of the following method:

@ServiceActivator(inputChannel = "producerChannel")
public MessageHandler kafkaMessageHandler() {
    KafkaProducerMessageHandler<String, String> handler =
        new KafkaProducerMessageHandler<>(kafkaTemplate());
    handler.setMessageKeyExpression(new LiteralExpression("kafka-integration"));

    return handler;
}

My pom.xml is:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-integration</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-kafka</artifactId>
        <version>2.3.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

What am I missing?

Gary Russell
2#
Gary Russell Reply to 2017-12-07 23:16:37Z

See the compatibility matrix on the Spring for Apache Kafka project page.

Spring Integration Kafka 2.3.x requires spring-kafka version 1.3.x.

Boot 1.5.x pulls in 1.1.x by default.

Add <version>1.3.2.RELEASE</version> to the spring-kafka dependency.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.303647 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO