question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ClassCastException with the latest snapshot build

See original GitHub issue

Getting the following when having key as string. Was working well till last week. However, today first had to upgrade the dependency on spring-kafka to 2.1.3.BUILD-SNAPSHOT (as the empty constructor was StreamFactoryBean was not there in 2.1.2-RELEASE). Once this was resolved, started to get this error.

tried setting:

spring.cloud.stream.bindings.input.consumer.key.deserializer: org.apache.kafka.common.serialization.StringDeserializer

spring.cloud.stream.kstream.bindings.output.producer.keySerde: org.apache.kafka.common.serialization.Serdes$StringSerde

however, they were not getting set (seen in the spring-boot startup logs).

I think this is related to changes in KStreamListenerSetupMethodOrchestrator.java

Exception in thread "eventMetricRecorder-73aa1b44-a9bf-4087-9ccc-39b32f145d69-StreamThread-1" java.lang.ClassCastException: [B cannot be cast to java.lang.String at org.apache.kafka.streams.kstream.internals.KStreamMap$KStreamMapProcessor.process(KStreamMap.java:41) at org.apache.kafka.streams.processor.internals.ProcessorNode$1.run(ProcessorNode.java:46) at org.apache.kafka.streams.processor.internals.StreamsMetricsImpl.measureLatencyNs(StreamsMetricsImpl.java:208) at org.apache.kafka.streams.processor.internals.ProcessorNode.process(ProcessorNode.java:124) at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:85) at org.apache.kafka.streams.kstream.internals.KStreamMap$KStreamMapProcessor.process(KStreamMap.java:42) at org.apache.kafka.streams.processor.internals.ProcessorNode$1.run(ProcessorNode.java:46) at org.apache.kafka.streams.processor.internals.StreamsMetricsImpl.measureLatencyNs(StreamsMetricsImpl.java:208) at org.apache.kafka.streams.processor.internals.ProcessorNode.process(ProcessorNode.java:124) at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:85) at org.apache.kafka.streams.kstream.internals.KStreamPassThrough$KStreamPassThroughProcessor.process(KStreamPassThrough.java:33) at org.apache.kafka.streams.processor.internals.ProcessorNode$1.run(ProcessorNode.java:46) at org.apache.kafka.streams.processor.internals.StreamsMetricsImpl.measureLatencyNs(StreamsMetricsImpl.java:208) at org.apache.kafka.streams.processor.internals.ProcessorNode.process(ProcessorNode.java:124) at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:99) at org.apache.kafka.streams.kstream.internals.KStreamBranch$KStreamBranchProcessor.process(KStreamBranch.java:45) at org.apache.kafka.streams.processor.internals.ProcessorNode$1.run(ProcessorNode.java:46) at org.apache.kafka.streams.processor.internals.StreamsMetricsImpl.measureLatencyNs(StreamsMetricsImpl.java:208) at org.apache.kafka.streams.processor.internals.ProcessorNode.process(ProcessorNode.java:124) at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:85) at org.apache.kafka.streams.kstream.internals.KStreamMap$KStreamMapProcessor.process(KStreamMap.java:42) at org.apache.kafka.streams.processor.internals.ProcessorNode$1.run(ProcessorNode.java:46) at org.apache.kafka.streams.processor.internals.StreamsMetricsImpl.measureLatencyNs(StreamsMetricsImpl.java:208) at org.apache.kafka.streams.processor.internals.ProcessorNode.process(ProcessorNode.java:124) at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:85) at org.apache.kafka.streams.processor.internals.SourceNode.process(SourceNode.java:80) at org.apache.kafka.streams.processor.internals.StreamTask.process(StreamTask.java:216) at org.apache.kafka.streams.processor.internals.AssignedTasks.process(AssignedTasks.java:403) at org.apache.kafka.streams.processor.internals.TaskManager.process(TaskManager.java:317) at org.apache.kafka.streams.processor.internals.StreamThread.processAndMaybeCommit(StreamThread.java:942) at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:822) at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:774) at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:744)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sobychackocommented, Feb 16, 2018

@tambre These two properties should work now:

spring.cloud.stream.kafka.streams.bindings.input.consumer.keySerde: org.apache.kafka.common.serialization.Serdes$StringSerde

spring.cloud.stream.kafka.streams.bindings.output.producer.keySerde: org.apache.kafka.common.serialization.Serdes$StringSerde

When you rely on Kafka provided serdes on the inbound and outbound, you should set these two flags to true as the defaults are false for them.

spring.cloud.stream.bindings.input.consumer.useNativeDecoding: true and spring.cloud.stream.bindings.output.producer.useNativeEncoding: true

0reactions
tambrecommented, Feb 20, 2018

@sobychacko thanks for your help

Read more comments on GitHub >

github_iconTop Results From Across the Web

ClassCastException when casting looked-up EJB view in AS7
This is a bug in AS7: https://issues.jboss.org/browse/AS7-1658. One possible workaround is not to cast the returned object, and then use it to fire...
Read more >
ClassCastException: Map cannot be cast to Nothing
I'm working against the latest snapshot - just pulled and re-tested before I wrote this up. I'm writing a smoke test that hits...
Read more >
Getting ClassCastException while getting LoggerContext
It was failing. So, I took latest log4j-core jar from "https://repository.apache.org/content/groups/snapshots/org/apache/logging ...
Read more >
[soapUi 4.5.1] ClassCastException bug is still there
Unfortunately I tested soapUI 4.5.1.1-SNAPSHOT "Build Date 2012/07/09 00:06" a few minutes ago and I still have the same issue.
Read more >
481443 – CLassCastException While Downloading ... - Bugs
When I run a Maven build that includes the repo location http://hge.javaforge.com/mercurialeclipse-snapshots Tycho fails after throwing a ClassCastException ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found