Dependency name inconsistent in google protobuf 2.5.0

java, protocol-buffers

Solution

I think this relates to your other question. It is important that a particular `.proto` file is always imported with exactly the same name. The compiled classes from `descriptor.proto` are included in the protobuf runtime, and it understands the name to be `google/protobuf/descriptor.proto`. If you made a copy of `descriptor.proto` and did not put it into a directory called `google/protobuf`, but instead just said `import "descriptor.proto";` in your own file, you will get this error, because the file names don't match.

Problem

I have an web application which I run in windows and linux environment. In linux and only linux I'm getting following exception: ``` Caused by: java.lang.IllegalArgumentException: Invalid embedded descriptor for "moop_shared.proto". at com.google.protobuf.Descriptors$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:301) ... Caused by: com.google.protobuf.Descriptors$DescriptorValidationException: moop_shared.proto: Dependencies passed to FileDescriptor.buildFrom() don't match those listed in the FileDescriptorProto. at com.google.protobuf.Descriptors$FileDescriptor.buildFrom(Descriptors.java:246) at com.google.protobuf.Descriptors$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:299) ... ``` So I debugged it both locally and remotely comparing the result. I can't understand the following: Env: protobuf-java-2.5.0 java 7 In both cases I run the very same webapp and I'm on the very same place in code which is `com.google.protobuf.Descriptors.java#245` see code For the context ``` ... for (int i = 0; i < proto.getDependencyCount(); i++) { HERE --> if (!dependencies[i].getName().equals(proto.getDependency(i))) { throw new DescriptorValidationException(result, "Dependencies passed to FileDescriptor.buildFrom() don't match " + "those listed in the FileDescriptorProto."); } } ... ``` And here are the information from debugger: Windows: ``` dependencies[i].getName() = {java.lang.String@3681}"descriptor.proto" proto.getDependency(i) = {java.lang.String@3682}"descriptor.proto" dependencies[i].getClass().getProtectionDomain().getCodeSource().getLocation().getPath() = {java.lang.String@3846}"/C:/Apps/Apache/jakarta/tomcat/webapps/ROOT/WEB-INF/lib/protobuf-java-2.5.0.jar" ``` Linux: ``` dependencies[i].getName() = {java.lang.String@2444}"google/protobuf/descriptor.proto" proto.getDependency(i) = {java.lang.String@2445}"descriptor.proto" dependencies[i].getClass().getProtectionDomain().getCodeSource().getLocation().getPath() = {java.lang.String@2608}"/tmp/jetty-0.0.0.0-8080-cnc-webapp-1.6.3-SNAPSHOT.war-_-any-/webapp/WEB-INF/lib/protobuf-java-2.5.0.jar" ``` So both dependecies are loaded from the protobuf jar which is byte indetical (checked) but the result of `dependencies[i].getName()` is different which in the Linux case cause the `DescriptorValidationException`. This is something which is beside my understanding. Any help will be much appreciated.

Original source