On Tue, Sep 9, 2008 at 1:16 AM, Kenton Varda <[EMAIL PROTECTED]> wrote:
> That won't work. DynamicMessage is a different class; it does not know how > to instantiate the protocol-compiler-generated version of the class. > Instead, you should do: > > Message result = > messageInstance.newBuilderForType().mergeFrom(input).build(); > > Actually, you should check isInitialized() before calling build(), or use > buildPartial() instead, but that's a separate issue. > I changed my deserializing code to use the above, but I'm getting the same exception. I also tried to call isInitialized() on the instance given to me, and the instance is not initialized. That is, isInitialized() returned false. I'm plugging in to a large framework that I'm not entirely familiar with (Hadoop), so I can only speculate what's going on here. I think that the Message instance given to me was created with reflection and is not a valid Message. I'm making this claim because isInitialized() is returning false. Is there any other way to deserialize? Can you provide any other good approaches to debugging this? In the meantime, I'm going to take my example out of the large framework in hopes of better understanding the problem I'm having. > The protocol compiler would not allow you to use tag zero anyway. It looks > like your input data is not identical to the data written by the sender. > I'm confident that the sender data is the same data that is created when I serialize. Perhaps I'm serializing incorrectly? I'm creating a CodedOutputStream given an OutputStream and passing that to writeTo. However, I'm not using a CodedInputStream to deserialize. Should I be using Coded or non-Coded streams? I stopped using CodedOutputStream when serializing and got the following exception: com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type. at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:62) at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:410) at com.google.protobuf.FieldSet.mergeFieldFrom(FieldSet.java:454) at com.google.protobuf.FieldSet.mergeFrom(FieldSet.java:402) at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:248) at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:240) at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:329) at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:184) Thanks for your help, Kenton! I got a good feeling that I'm almost there :). Alex --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---