Deployment fails with Spring Kafka in EAP 7.2 or earlier
Issue
A war deployment with Spring Kafka fails with the following error. Is there a workaround?
14:54:03,115 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 77) MSC000001: Failed to start service jboss.deployment.unit."spring-kafka-demo.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.unit."spring-kafka-demo.war".undertow-deployment: java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controller' defined in VFS resource ["/content/spring-kafka-demo.war/WEB-INF/classes/com/redhat/cee/gss/example/springboot/kafka/kafkademo/Controller.class"]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kafkaTemplate' defined in class path resource [org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.kafka.core.KafkaTemplate]: Factory method 'kafkaTemplate' threw exception; nested exception is java.lang.VerifyError: Bad return type
...
Caused by: java.lang.VerifyError: Bad return type
Exception Details:
Location:
com/fasterxml/jackson/databind/cfg/MapperBuilder.streamFactory()Lcom/fasterxml/jackson/core/TokenStreamFactory; @7: areturn
Reason:
Type 'com/fasterxml/jackson/core/JsonFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/TokenStreamFactory' (from method signature)
Current Frame:
bci: @7
flags: { }
locals: { 'com/fasterxml/jackson/databind/cfg/MapperBuilder' }
stack: { 'com/fasterxml/jackson/core/JsonFactory' }
Bytecode:
0000000: 2ab4 0002 b600 08b0
at deployment.spring-kafka-demo.war//com.fasterxml.jackson.databind.json.JsonMapper.builder(JsonMapper.java:114)
at deployment.spring-kafka-demo.war//org.springframework.kafka.support.JacksonUtils.enhancedObjectMapper(JacksonUtils.java:55)
at deployment.spring-kafka-demo.war//org.springframework.kafka.support.DefaultKafkaHeaderMapper.<init>(DefaultKafkaHeaderMapper.java:112)
at deployment.spring-kafka-demo.war//org.springframework.kafka.support.converter.MessagingMessageConverter.<init>(MessagingMessageConverter.java:76)
at deployment.spring-kafka-demo.war//org.springframework.kafka.core.KafkaTemplate.<init>(KafkaTemplate.java:112)
at deployment.spring-kafka-demo.war//org.springframework.kafka.core.KafkaTemplate.<init>(KafkaTemplate.java:165)
at deployment.spring-kafka-demo.war//org.springframework.kafka.core.KafkaTemplate.<init>(KafkaTemplate.java:137)
at deployment.spring-kafka-demo.war//org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration.kafkaTemplate(KafkaAutoConfiguration.java:69)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at deployment.spring-kafka-demo.war//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 55 more
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7
- Spring Boot 2.6
- war packaging
- Spring for Apache Kafka 2.8
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.