Question

I am trying to write Kafka producer and consumer code in Java using Eclipse. I am have downloaded the Kafka jar file and loaded as external Jar file. And it solved the dependency problem.

However, there is always a unresolved error and the message looks like below:

Multiple markers at this line
- The type scala.Product cannot be resolved. It is indirectly referenced from required .class files
- The type scala.Serializable cannot be resolved. It is indirectly referenced from required .class 
 files

I really don't know what is going on and how to fix that error. Thanks.

enter image description here

Was it helpful?

Solution

UPDATED 4/26/2018

It appears that you need to have the Scala runtime library in your Eclipse project's classpath.

If you're using Maven (or some other repository-based build tool—highly recommended), then adding Kafka as a dependency should cause it to automatically download the corresponding Scala runtime library and include it on your project's classpath. For example,

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.12</artifactId>
    <version>1.1.0</version>
</dependency>

will cause Maven to download version 2.12.4 of the Scala runtime library.

Otherwise, you can install Scala (see http://scala-lang.org/) and add the installed scala-library.jar to your project's classpath manually. However, you should note that Scala minor releases (2.10.x, 2.11.x, 2.12.x, etc.) are not binary compatible with each other, so you should download the most recent bug-fix version of the minor release used to build your version of Kafka. (This minor version is appended to the name of the Kafka artifact, e.g. kafka_2.12 requires a Scala 2.12.x runtime library version.)

OTHER TIPS

Downloaded the scala libraries from http://scala-lang.org/download/ and added the scala-library.jar to the project, error resolved!

Delete the unneccessary jar files and keep exact version jar file. It worked for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top