Invalid embedded descriptor && Dependencies passed to FileDescriptor.buildFrom() don't match

1,162 views
Skip to first unread message

pipfiddle

unread,
Feb 24, 2010, 5:13:58 PM2/24/10
to Protocol Buffers
I'm having trouble with an import and can't figure out the problem.
I'm working in Java and am using the 2.3.0 release of protobuf (just
upgraded from 2.2.0 trying to solve the problem). I'm working on
windows. (Running protoc.exe from cygwin using forward slashes for
the commands below shows the same behavior.)

The situation is as follows:

I have a library with a message type (ExceptionWrapper) in it.
I have a separate project where one of the protobuf message types
(Task) needs to import the library proto.

When I try to run the compiled java code created for the message type
with the import, I get an error as attached below.

I've seen the posts which say this kind of error has to do with
incorrect -I/proto-path parameters but I'm not clear what exactly I'm
doing wrong.

The command i run to generate the java files is as follows:

[lib -- from project1 root] protoc proto\*.proto
--
java_out=src
[importing file -- from project2 root] protoc proto\*.proto --
java_out=src -I=proto -I=..\project1\proto

obviously, the lib file shouldn't be dependent on the importing file
so the two commands are different. I've also attached the example
code from the two proto files.

Any help would be greatly appreciated.

Thanks,
Jacques

----------------Error Message------------------
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.example.bus.TaskProtos$Task.<clinit>(TaskProtos.java:
436)
at com.example.bus.ExampleTest.main(ExampleTest.java:8)
Caused by: java.lang.IllegalArgumentException: Invalid embedded
descriptor for "TaskProtos.proto".
at com.google.protobuf.Descriptors
$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:286)
at com.example.bus.TaskProtos.<clinit>(TaskProtos.java:1089)
... 2 more
Caused by: com.google.protobuf.Descriptors
$DescriptorValidationException: TaskProtos.proto: Dependencies passed
to FileDescriptor.buildFrom() don't match those listed in the
FileDescriptorProto.
at com.google.protobuf.Descriptors
$FileDescriptor.buildFrom(Descriptors.java:231)
at com.google.protobuf.Descriptors
$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:284)
... 3 more


--------------Example Base File: "project1\proto\ProtoException.proto"
-----------------
package exception;


option java_package = "com.example.im";
option java_outer_classname = "ProtoException";


message ExceptionWrapper {
optional string exception_class = 1;
}


--------------Example Importing File: "project2\proto
\TaskProtos.proto" -----------------
package input;

option java_package = "com.example.bus";
option java_outer_classname = "TaskProtos";

import "ProtoException.proto";

message Task {
optional exception.ExceptionWrapper exception = 3;
}

Jason Hsueh

unread,
Feb 24, 2010, 5:38:31 PM2/24/10
to pipfiddle, Protocol Buffers
I believe you should be running protoc from the same directory, using the same --proto_path, for both commands. The imports should be relative to the common root directory.
modify the import in project2\proto\TaskProtos.proto:
import "project1/proto/ProtoException.proto"

$ protoc --proto_path=. project1\proto\*.proto ...
$ protoc --proto_path=. project2\proto\*.proto ...



--
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.


pipfiddle

unread,
Feb 24, 2010, 5:49:30 PM2/24/10
to Protocol Buffers
You are correct. That fixed the problem. Thank you for the help.

Jacques

On Feb 24, 2:38 pm, Jason Hsueh <jas...@google.com> wrote:
> I believe you should be running protoc from the same directory, using the
> same --proto_path, for both commands. The imports should be relative to the
> common root directory.
> modify the import in project2\proto\TaskProtos.proto:
> import "project1/proto/ProtoException.proto"
>
> $ protoc --proto_path=. project1\proto\*.proto ...
> $ protoc --proto_path=. project2\proto\*.proto ...
>

> > protobuf+u...@googlegroups.com<protobuf%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages