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


On Wed, Feb 24, 2010 at 2:13 PM, pipfiddle <jacquesnad...@gmail.com> wrote:

> 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;
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

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

Reply via email to