The generated java code crashes if I try to integrate it into an Eclipse Rich Client application

587 views
Skip to first unread message

Alsmom2005

unread,
Nov 11, 2010, 2:00:46 PM11/11/10
to Protocol Buffers
Hi,

I have problems integrating Java GPB generated code into an Eclipse
Rich Client Platform Application.

The same code works fine in a standalone java project but it crashes
in the RCP environment at the first 'usage' of an enum value defined
in GPB code:

Exception in thread "Thread-3" java.lang.ExceptionInInitializerError
at com.google.protobuf.DescriptorProtos
$FileDescriptorProto.<clinit>(DescriptorProtos.java:1687)
at com.google.protobuf.Descriptors
$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:338)
at NGCMOSMsg.NGCMOSMessages.<clinit>(NGCMOSMessages.java:11255)
at NGCMOSMsg.NGCMOSMessages$MOSEndpoints.<clinit>(NGCMOSMessages.java:
353)
at communication.PostOffice.<init>(PostOffice.java:31)
at communication.PostOffice.getPostOffice(PostOffice.java:106)
at ca.mda.moscs.common.Utilities$1.run(Utilities.java:130)
Caused by: java.lang.IllegalArgumentException: Failed to parse
protocol buffer descriptor for generated code.
at com.google.protobuf.Descriptors
$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:341)
at
com.google.protobuf.DescriptorProtos.<clinit>(DescriptorProtos.java:
12656)
... 7 more
Caused by: com.google.protobuf.InvalidProtocolBufferException:
Protocol message tag had invalid wire type.
at
com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:
86)
at com.google.protobuf.UnknownFieldSet
$Builder.mergeFieldFrom(UnknownFieldSet.java:600)
at com.google.protobuf.GeneratedMessage
$Builder.parseUnknownField(GeneratedMessage.java:320)
at com.google.protobuf.DescriptorProtos$DescriptorProto
$Builder.mergeFrom(DescriptorProtos.java:2742)
at com.google.protobuf.DescriptorProtos$DescriptorProto
$Builder.mergeFrom(DescriptorProtos.java:1)
at
com.google.protobuf.CodedInputStream.readMessage(CodedInputStream.java:
285)
at com.google.protobuf.DescriptorProtos$FileDescriptorProto
$Builder.mergeFrom(DescriptorProtos.java:1143)
at com.google.protobuf.DescriptorProtos$FileDescriptorProto
$Builder.mergeFrom(DescriptorProtos.java:1)
at com.google.protobuf.AbstractMessage
$Builder.mergeFrom(AbstractMessage.java:288)
at com.google.protobuf.AbstractMessage
$Builder.mergeFrom(AbstractMessage.java:1)
at com.google.protobuf.AbstractMessageLite
$Builder.mergeFrom(AbstractMessageLite.java:184)
at com.google.protobuf.AbstractMessage
$Builder.mergeFrom(AbstractMessage.java:792)
at com.google.protobuf.AbstractMessage
$Builder.mergeFrom(AbstractMessage.java:1)
at com.google.protobuf.AbstractMessageLite
$Builder.mergeFrom(AbstractMessageLite.java:174)
at com.google.protobuf.AbstractMessage
$Builder.mergeFrom(AbstractMessage.java:785)
at com.google.protobuf.DescriptorProtos
$FileDescriptorProto.parseFrom(DescriptorProtos.java:820)
at com.google.protobuf.Descriptors
$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:338)
... 8 more
java.lang.NullPointerException
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper
$ComponentPresentationCache.getCacheFile(ComponentPresentationHelper.java:
428)
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper
$ComponentPresentationCache.<init>(ComponentPresentationHelper.java:
322)
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper.getCache(ComponentPresentationHelper.java:
299)
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper.access
$0(ComponentPresentationHelper.java:295)
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper
$1.run(ComponentPresentationHelper.java:504)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
java.lang.NullPointerException
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper
$ComponentPresentationCache.getCacheFile(ComponentPresentationHelper.java:
428)
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper
$ComponentPresentationCache.<init>(ComponentPresentationHelper.java:
322)
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper.getCache(ComponentPresentationHelper.java:
299)
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper.access
$0(ComponentPresentationHelper.java:295)
at
com.instantiations.designer.core.xml.model.description.ComponentPresentationHelper
$1.run(ComponentPresentationHelper.java:504)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


Can anybody give me a hint to address this issue?

Thank you in advance!

Kenton Varda

unread,
Nov 16, 2010, 10:57:53 PM11/16/10
to Alsmom2005, Protocol Buffers
The generated code contains a big string literal which contains metadata about the types.  The metadata is itself a protocol buffer, and is decoded at startup.  It looks like it is somehow being corrupted in your environment.  I don't know how that would happen.  I recently wrote an Eclipse plugin that used protocol buffers and did not see any problems.

That said, you can try adding this to your .proto file:
  option optimize_for = LITE_RUNTIME;

This turns off a number of features, including self-description.  Thus, the generated code will no longer contain an embedded descriptor at all.


--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.


Reply all
Reply to author
Forward
0 new messages