Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Proto class is not a valid proto3 message class #44

Open
iguenkinrl opened this issue Feb 7, 2020 · 2 comments
Open

Proto class is not a valid proto3 message class #44

iguenkinrl opened this issue Feb 7, 2020 · 2 comments

Comments

@iguenkinrl
Copy link

Hello,

I've installed protobuf convertor and build my own protobuf definition jar.
I've put it into ../confluent/share/java/kafka-serde-tools/ directory
in my connector definition I set up
"value.converter.protoClassName":"com.rl.messaging.messages.BusinessEventMessages$BusinessEvent"
when I'm starting connector I've got the following error message ERROR Failed to start task rabbitMQ-src-0 (org.apache.kafka.connect.runtime.Worker:473) org.apache.kafka.connect.errors.ConnectException: Proto class com.rl.messaging.messages.BusinessEventMessages$BusinessEvent is not a valid proto3 message class
in ProtobufConverter.java code I found the following entry
String protoClassNameString = protoClassName.toString(); try { protobufData = new ProtobufData(Class.forName(protoClassNameString).asSubclass(com.google.protobuf.GeneratedMessageV3.class), legacyNameString); } catch (ClassNotFoundException e) { throw new ConnectException("Proto class " + protoClassNameString + " not found in the classpath"); } catch (ClassCastException e) { throw new ConnectException("Proto class " + protoClassNameString + " is not a valid proto3 message class"); }
that means that my own protobuf should be a subclass of com.google.protobuf.GeneratedMessageV3.class

How should I build my own protobuf jar to solve this error ?

BusinessEventMessages.proto.zip

@bagipriyank
Copy link

Change the first line in BusinessEventMessages.proto from syntax = "proto2"; to syntax = "proto3";. That tells protoc to compile a generated class for proto3. Please note that there are some differences in proto2 v/s proto3. There is no optional keyword as every field is optional by default - among some other differences. But I mentioned optional specifically since you are using it with in your messages.

@fhajiyev
Copy link

@bagipriyank Hello, I'm facing this issue at the moment. Does blueapron only support proto3? Our proto needs to be proto2 due to certain restrictions. Is there a configuration for specifying the type of proto? Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants