Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:58:58+00:00 2026-06-07T12:58:58+00:00

are Classes generated by the Protostuff code generator compatible with those created by Protobuf?

  • 0

are Classes generated by the Protostuff code generator compatible with those created by Protobuf?

I tried to (de)serialize some simple messages and got several exceptions:

Proto-File (WrapperClass.proto)

package tutorial;
option java_package = "com.example.tutorial";
message ProjectId {
    required int32 id = 1;
}
message UserId {
    required ProjectId project = 1;
    required int32 projectUserId = 2;
}
message ChannelId {
    required ProjectId project = 1;
    required string name = 2;
}

Protostuff to Protobuf Test (example)

ProjectId projectId = new ProjectId(1);
byte[] projectarray = ProtostuffIOUtil.toByteArray(projectId, ProjectId.getSchema(), buffer);
com.example.tutorial.WrapperClass.ProjectId returnBufProject = com.example.tutorial.WrapperClass.ProjectId.parseFrom(projectarray);

Problem:

Everything works for ProjectId, but for UserId and ChannelId (everything a little bit more complex), i get:

com.google.protobuf.InvalidProtocolBufferException: Message missing required fields: project
    at com.google.protobuf.UninitializedMessageException.asInvalidProtocolBufferException(UninitializedMessageException.java:81)
    at com.example.tutorial.WrapperClass$ChannelId$Builder.buildParsed(Test.java:1278)
    at com.example.tutorial.WrapperClass$ChannelId$Builder.access$17(Test.java:1273)
    at com.example.tutorial.WrapperClass$ChannelId.parseFrom(Test.java:1142)
    ...

And the other way around:

Protobuf to Protostuff Test (example)

com.example.tutorial.WrapperClass.ProjectId projectId2 = com.example.tutorial.WrapperClass.ProjectId.newBuilder().setId(1).build();
byte[] project2array = projectId2.toByteArray();
ProjectId returnStufProject = new ProjectId();
ProtostuffIOUtil.mergeFrom(project2array, returnStufProject, ProjectId.getSchema());

Problem

again, for everything other than the ProjectId, there is an exception:

java.lang.RuntimeException: Reading from a byte array threw an IOException (should never happen).
    at com.dyuproject.protostuff.IOUtil.mergeFrom(IOUtil.java:53)
    at com.dyuproject.protostuff.ProtostuffIOUtil.mergeFrom(ProtostuffIOUtil.java:96)
    at JacksonTest.main(JacksonTest.java:92)
Caused by: com.dyuproject.protostuff.ProtobufException: Protocol message contained an invalid tag (zero).
    at com.dyuproject.protostuff.ProtobufException.invalidTag(ProtobufException.java:98)
    at com.dyuproject.protostuff.ByteArrayInput.readFieldNumber(ByteArrayInput.java:220)
    at com.example.tutorial.ProjectId$1.mergeFrom(ProjectId.java:115)
    at com.example.tutorial.ProjectId$1.mergeFrom(ProjectId.java:1)
    at com.dyuproject.protostuff.ByteArrayInput.mergeObjectEncodedAsGroup(ByteArrayInput.java:390)
    at com.dyuproject.protostuff.ByteArrayInput.mergeObject(ByteArrayInput.java:362)
    at com.example.tutorial.UserId$1.mergeFrom(UserId.java:138)
    at com.example.tutorial.UserId$1.mergeFrom(UserId.java:1)
    at com.dyuproject.protostuff.IOUtil.mergeFrom(IOUtil.java:43)
    ... 2 more

Am i trying something impossible or do i only do something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:59:01+00:00Added an answer on June 7, 2026 at 12:59 pm

    The problem was simple:
    Instead of using ProtostuffIOUtil to (de)serialize my messages i need to use ProtobufIOUtil

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two simple classes generated by code first. public class Company { public
We've generated some (well a lot) of classes using HyperJAXB. All of the classes
Let's look at the code, generated by F# for simple function: let map_add valueToAdd
I have a relatively simple package of 8 Java classes generated from an XML
I have some classes generated from WSDL files by the Axis Framework. In one
I'm looking at some work updating classes generated from xsds. I think this would
When I update my Entity model my code generated classes (ie. Model.tt) are rebuild,
I have generated classes from xsd and want to serialize the DateTime . My
I have the following classes generated by the Reverse engineering tool (Entity Framework Power
I have two classes generated by LINQ2SQL both from the same table so they

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.