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

**URL:** <https://forum.confluent.io/t/exception-in-thread-main-java-lang-noclassdeffounderror-com-google-protobuf-messageorbuilder/4032>\
**Category:** Schema Registry\
**Created:** [30 January 2022 04:37 UTC](https://forum.confluent.io/t/exception-in-thread-main-java-lang-noclassdeffounderror-com-google-protobuf-messageorbuilder/4032 "2022-01-30T04:37:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xsqian](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/xsqian/32/1534_2.png) [@xsqian](https://forum.confluent.io/u/xsqian)\
**Post date:** [30 January 2022 04:37 UTC](https://forum.confluent.io/t/exception-in-thread-main-java-lang-noclassdeffounderror-com-google-protobuf-messageorbuilder/4032/1 "2022-01-30T04:37:43Z")

</div>

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

> **[demo-scene/getting-started-with-ccloud-java at master · confluentinc/demo-scene](https://github.com/confluentinc/demo-scene/tree/master/getting-started-with-ccloud-java)**
>
> master/getting-started-with-ccloud-java

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.

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

```

Any quick pointer what is the issue?  
Thanks,  
xsqian

---

<div class="post-metadata">

**Author:** ![gklijs](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/gklijs/32/223_2.png) [@gklijs](https://forum.confluent.io/u/gklijs)\
**Post date:** [30 January 2022 05:13 UTC](https://forum.confluent.io/t/exception-in-thread-main-java-lang-noclassdeffounderror-com-google-protobuf-messageorbuilder/4032/2 "2022-01-30T05:13:22Z")

</div>

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](https://github.com/confluentinc/demo-scene/blob/375212d7b5fe07609e70990c6ee6b91e2433f37f/getting-started-with-ccloud-java/src/main/java/io/confluent/cloud/demo/domain/SensorReadingImpl.java#L12).  
You want [https://github.com/protocolbuffers/protobuf/blob/15add1af49f13d1661d3910d0eb6697b415a19d1/java/core/src/main/java/com/google/protobuf/MessageOrBuilder.Java](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

```xml
<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.

---

<div class="post-metadata">

**Author:** ![xsqian](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/xsqian/32/1534_2.png) [@xsqian](https://forum.confluent.io/u/xsqian)\
**Post date:** [30 January 2022 05:57 UTC](https://forum.confluent.io/t/exception-in-thread-main-java-lang-noclassdeffounderror-com-google-protobuf-messageorbuilder/4032/3 "2022-01-30T05:57:19Z")

</div>

> [@gklijs](#):
>
> ```auto
> <dependency>
> <groupId>com.google.protobuf</groupId>
> <artifactId>protobuf-java</artifactId>
> <version>3.19.4</version>
> <type>bundle</type>
> </dependency>
> 
> ```

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

```auto
(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>% 

```

---

<div class="post-metadata">

**Author:** ![gklijs](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/gklijs/32/223_2.png) [@gklijs](https://forum.confluent.io/u/gklijs)\
**Post date:** [30 January 2022 08:16 UTC](https://forum.confluent.io/t/exception-in-thread-main-java-lang-noclassdeffounderror-com-google-protobuf-messageorbuilder/4032/4 "2022-01-30T08:16:21Z")

</div>

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

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

```

To the `repositories` section.
