Exception in thread "main" java.lang.NoClassDefFoundError: com/google/protobuf/MessageOrBuilder

Hi there,
I am trying out the schema registry with protobuf as in this example.

However, when I run this java -cp target/getting-started-with-ccloud-1.0.jar io.confluent.cloud.demo.ProducerApp, I got the following error message.

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/protobuf/MessageOrBuilder

Any quick pointer what is the issue?
Thanks,
xsqian

Seems like in the generated code it want to register all the extensions, but those can’t be found on the class path, demo-scene/SensorReadingImpl.java at 375212d7b5fe07609e70990c6ee6b91e2433f37f · confluentinc/demo-scene · GitHub.
You want https://github.com/protocolbuffers/protobuf/blob/15add1af49f13d1661d3910d0eb6697b415a19d1/java/core/src/main/java/com/google/protobuf/MessageOrBuilder.Java among others on the classpath.
You can do this by adding

<dependency>
  <groupId>com.google.protobuf</groupId>
  <artifactId>protobuf-java</artifactId>
  <version>3.19.4</version>
  <type>bundle</type>
</dependency>

to the maven dependencies in the pom file.

@gklijs Thank you for the answer. I actually running into another issue: (even with -U)

(base) xsqian@[21:55:10]<getting-started-with-ccloud-java>% mvn -U clean package
[INFO] Scanning for projects...
[INFO] 
[INFO] --------< io.confluent.cloud.demo:getting-started-with-ccloud >---------
[INFO] Building getting-started-with-ccloud 1.0
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from confluent: https://packages.confluent.io/maven/com/google/protobuf/protobuf-java/3.19.4/protobuf-java-3.19.4.bundle
Downloading from central: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java/3.19.4/protobuf-java-3.19.4.bundle
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.299 s
[INFO] Finished at: 2022-01-29T21:55:15-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project getting-started-with-ccloud: Could not resolve dependencies for project io.confluent.cloud.demo:getting-started-with-ccloud:jar:1.0: Could not find artifact com.google.protobuf:protobuf-java:bundle:3.19.4 in confluent (https://packages.confluent.io/maven/) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
(base) xsqian@[21:55:15]<getting-started-with-ccloud-java>% 

Since you already have the Confluent repo in the repositories section, it will nu longer look in Maven Central, the default. So you need to add

<repository>
      <id>maven-central</id>
      <name>Maven central</name>
      <url>https://repo1.maven.org/maven2/</url>
</repository>

To the repositories section.