-
Notifications
You must be signed in to change notification settings - Fork 15.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java] The release notes state that compatibility was restored in v27.2, but it is not compatible #17247
Comments
I'm suspecting this is an ABI incompatibility. When you compile generated code against v4.27.2 what can go into the class file is |
Incidentally, an exception occurs at runtime in the reverse case(using the code generated with protobuf v27.2 in a protobuf-java v3.25.3 environment). |
@be-hase, that would not be supported. Newer generated code can make use of newer runtime features. For basically all libraries in the ecosystem, downgrading dependencies is not directly supported. |
@ejona86 |
I have prepared a reproduction repository, so please feel free to use it. |
What @be-hase noticed means that protobuf-java 4.27.1 is incompatible with grpc-java 1.64.0 Even |
v4.27.2 should have re-established compatibility with v3.25.x gencode from source, but looks like additional shims will need to be added to further restore compatibility with v3.25.x gencode in jars compiled against 3.25.x runtime (per ejona86's prior comment). Also can confirm that new gencode + old runtime is never allowed. You can see our full policies on this in https://protobuf.dev/support/cross-version-runtime-guarantee. |
OK, I see.
I am waiting for the shims to be added. |
Another example ( --protoc-gen-scala_out: java.lang.NoClassDefFoundError: com/google/protobuf/GeneratedMessageV3$ExtendableMessageOrBuilder
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at scalapb.options.Scalapb.<clinit>(Scalapb.java:23793)
at scalapb.ScalaPbCodeGenerator$.registerExtensions(ScalaPbCodeGenerator.scala:13)
at protocgen.CodeGenApp.run(CodeGenApp.scala:42)
at protocgen.CodeGenApp.run$(CodeGenApp.scala:39)
at scalapb.ScalaPbCodeGenerator$.run(ScalaPbCodeGenerator.scala:11)
at protocgen.CodeGenApp.main(CodeGenApp.scala:27)
at protocgen.CodeGenApp.main$(CodeGenApp.scala:26)
at scalapb.ScalaPbCodeGenerator$.main(ScalaPbCodeGenerator.scala:11)
at scalapb.ScalaPbCodeGenerator.main(ScalaPbCodeGenerator.scala)
Caused by: java.lang.ClassNotFoundException: com.google.protobuf.GeneratedMessageV3$ExtendableMessageOrBuilder
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
... 27 more Using |
Thanks, we have a repro for this on our side and are aware that additional shims would be needed for the other inner classes (incl. GeneratedMessageV3.ExtendableMessageOrBuilder) as well |
…xes protobuf dep. issue (#829) Fixes #490 ### Changelog - [x] Remove Cloud SQL flavor from upstream, keeping Vertex AI Search (now agent builder). Rationale: all user feedback so far has been for the Agent Builder flavor. GCP already has multiple Cloud SQL RAG sample apps, including the [DB Retrieval App](https://github.com/GoogleCloudPlatform/genai-databases-retrieval-app) and this [Jump Start Solution](https://cloud.google.com/architecture/ai-ml/generative-ai-rag). Removing the Cloud SQL flavor helps reduce duplicated code and maintenance overhead in this repo. If we hear user feedback or requests for the Cloud SQL flavor to return, I will re-add. - [x] Swap in Agent Builder naming for all instances of Vertex AI Search. - [x] Upgrade model to Gemini 1.5 Flash. - [x] Java backend - commit `MavenWrapper`. This is [somewhat contentious](https://stackoverflow.com/questions/47240546/should-the-mvnw-files-be-added-to-the-repository) but will help speed up deployment for new users and make sure folks are using the right Maven version. - [x] Java backend - Fix [protobuf forward-breaking change](protocolbuffers/protobuf#17247) by switching all GCP client libs to the latest `libraries-bom`. Remove specific versions of clients and dependencies. This seemed to resolve the problem, which I believe was caused by multiple underlying and incompatible protobuf versions. ---------
…xes protobuf dep. issue (GoogleCloudPlatform#829) Fixes GoogleCloudPlatform#490 ### Changelog - [x] Remove Cloud SQL flavor from upstream, keeping Vertex AI Search (now agent builder). Rationale: all user feedback so far has been for the Agent Builder flavor. GCP already has multiple Cloud SQL RAG sample apps, including the [DB Retrieval App](https://github.com/GoogleCloudPlatform/genai-databases-retrieval-app) and this [Jump Start Solution](https://cloud.google.com/architecture/ai-ml/generative-ai-rag). Removing the Cloud SQL flavor helps reduce duplicated code and maintenance overhead in this repo. If we hear user feedback or requests for the Cloud SQL flavor to return, I will re-add. - [x] Swap in Agent Builder naming for all instances of Vertex AI Search. - [x] Upgrade model to Gemini 1.5 Flash. - [x] Java backend - commit `MavenWrapper`. This is [somewhat contentious](https://stackoverflow.com/questions/47240546/should-the-mvnw-files-be-added-to-the-repository) but will help speed up deployment for new users and make sure folks are using the right Maven version. - [x] Java backend - Fix [protobuf forward-breaking change](protocolbuffers/protobuf#17247) by switching all GCP client libs to the latest `libraries-bom`. Remove specific versions of clients and dependencies. This seemed to resolve the problem, which I believe was caused by multiple underlying and incompatible protobuf versions. ---------
Protobuf 4.x introduced a breaking change. Version 27.2 introduced a set of stubs to make proto backward compatible (https://github.com/protocolbuffers/protobuf/releases/tag/v27.2) but this seems to be incomplete (protocolbuffers/protobuf#17247). #31 PiperOrigin-RevId: 653514325 Change-Id: I10ac3cab3a8856864052619569e6be0492dca274
Protobuf 4.x introduced a breaking change. Version 27.2 introduced a set of stubs to make proto backward compatible (https://github.com/protocolbuffers/protobuf/releases/tag/v27.2) but this seems to be incomplete (protocolbuffers/protobuf#17247). tink-crypto#31 PiperOrigin-RevId: 653514325 Change-Id: I10ac3cab3a8856864052619569e6be0492dca274 (cherry picked from commit 9fdb4e2)
I know it hasn't been that long, but it looks like another protobuf release has occurred and it doesn't seem like this issue is resolved yet. Are improvements to gencode backwards compatibility still on-track to hit a v27.x release, or are there blockers preventing this issue from being resolved? |
Improvements to gencode backward compatibilities are still being worked on and are planned for a v27.x release -- v27.3 made some unrelated fixes and doesn't include compat improvements yet. More extensive shims will be needed for binary compatibility with jars compiled against 25.x runtime. |
Could you please provide a projected release date? My clients are waiting for the fix. |
Does 4.28.rc1 fix the problem? |
…xes protobuf dep. issue (GoogleCloudPlatform#829) Fixes GoogleCloudPlatform#490 ### Changelog - [x] Remove Cloud SQL flavor from upstream, keeping Vertex AI Search (now agent builder). Rationale: all user feedback so far has been for the Agent Builder flavor. GCP already has multiple Cloud SQL RAG sample apps, including the [DB Retrieval App](https://github.com/GoogleCloudPlatform/genai-databases-retrieval-app) and this [Jump Start Solution](https://cloud.google.com/architecture/ai-ml/generative-ai-rag). Removing the Cloud SQL flavor helps reduce duplicated code and maintenance overhead in this repo. If we hear user feedback or requests for the Cloud SQL flavor to return, I will re-add. - [x] Swap in Agent Builder naming for all instances of Vertex AI Search. - [x] Upgrade model to Gemini 1.5 Flash. - [x] Java backend - commit `MavenWrapper`. This is [somewhat contentious](https://stackoverflow.com/questions/47240546/should-the-mvnw-files-be-added-to-the-repository) but will help speed up deployment for new users and make sure folks are using the right Maven version. - [x] Java backend - Fix [protobuf forward-breaking change](protocolbuffers/protobuf#17247) by switching all GCP client libs to the latest `libraries-bom`. Remove specific versions of clients and dependencies. This seemed to resolve the problem, which I believe was caused by multiple underlying and incompatible protobuf versions. ---------
Firstly, please be mindful that when you reply to this issue it is notifying all of us following it. (I realize I'm doing that too, but alas.) Secondly, I do not think the compatibility shims have been improved yet. e.g. Finally, the latest status update suggests that the work to fix this is not blocked and is slated to come in a future v27.x release. There is no ETA right now. Unfortunately, I think we'll just need to be patient for now. A future v27 protobuf release should give us a clean path forward. |
Good news, it looks like shim was added in v28.0-rc3.
|
Hello Community, Yes, we've added more-complete shims in PBJ 4.28.0-rc3. If possible please try out the 4.28.0-rc3 runtime with your PBJ 3.x gencode at your earliest convenience and let us know if you discover incompatibilities that we've missed during testing. Thank you for your patience! |
Looks good in my testing with gRPC! I don't think we mix protos from different sources into one message tree, so maybe there could be something lurking there. But look great from what I can tell! 🎉 |
I have confirmed that the issue has been fixed in my reproducible repository as well. |
We should be releasing v4.27.4 and v4.28.0 with the patch this week as well. |
I'm probably holding this wrong, but my attempt to get Bazel itself to use the latest protobuf didn't work. Since no PR was sent to the Bazel Central Registry for protobuf 28.0-rc3, I had to use a git override to point it at the tag. But the error message says:
which indeed shows that the MODULE.bazel file in the 28.x branch still doesn't contain proper references to its I then tried 29.0-dev (basically tip-of-tree), and still got the same error message as before:
|
4.27.4 tagged artifacts are still missing though: Second edit: They are there now |
I am not having success with either 4.27.4 or 4.28.0. Can others verify that the issue is resolved for them in these releases? |
@bjoernmayer, mvnrepository.com has no relationship with Maven Central. The site is not an authority for something being available. search.maven.org/central.sonatype.com are much better about indexing quickly, but even then stuff can show up in repo1 and be downloadable before it is indexed. @estomagordo, both 4.27.4 and 4.28.0 worked fine for me. Testing against different versions of proto-google-common-protos, it seems 4.27.4/4.28 is at least partly compatible back to 21.8 (Oct 2022). 21.7 fails (NoSuchMethodError: makeExtensionsImmutable()) and 21.9 succeeds. |
Version 4.28.0 from the Maven Repository works with the latest Cloud Pub/Sub Java library. Thank you so much. |
I think it's okay to close this issue. thanks. :) |
Excellent. Thank you @be-hase, @ejona86 , @bjoernmayer, and @emintz for verifying. Happy buffering. |
Certainly solved the majority of the issues I was seeing, thanks! Out of curiosity, does this look like the same thing? We are getting it with 4.28.0 off Central with Android instrumented tests.
|
@mjones-vsat, that looks similar to what I saw. |
Summary
When trying to use the code generated with protobuf v25.3 in a protobuf-java v4.27.2 environment, a compilation error occurs.
In v27.2, GeneratedMessageV3.Builder does not exist.
Links
The text was updated successfully, but these errors were encountered: