I'm getting the following exception when calling 
TypeStrings.getDescriptor():

java.lang.ExceptionInInitializerError
    at com.company.DummyTests.testDynamicOption(DummyTests.java:23)
<22 internal calls>
Caused by: java.lang.IllegalArgumentException: Invalid embedded descriptor 
for "type_strings.proto".
    at 
com.google.protobuf.Descriptors$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:294)
    at com.company.TypeStrings.<clinit>(TypeStrings.java:487)
    ... 26 more
Caused by: com.google.protobuf.Descriptors$DescriptorValidationException: 
type_strings.proto: Dependencies passed to FileDescriptor.buildFrom() don't 
match those listed in the FileDescriptorProto.
    at 
com.google.protobuf.Descriptors$FileDescriptor.buildFrom(Descriptors.java:239)
    at 
com.google.protobuf.Descriptors$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:292)
    ... 27 more


The call is just this:
public void testDynamicOption() throws Exception
{
  System.out.println(TypeStrings.getDescriptor());
}

type_strings.proto:
package com.company.proto;

option java_package = "com.company.proto";

import 'descriptor.proto'; //The protobuf descriptor proto file

enum StringType {
  UNKNOWN = 1;
  CHAR_ARRAY = 2;
  BYTE_ARRAY = 3;
}

message FieldOptions {
  optional StringType string_type = 1;
}

extend google.protobuf.FieldOptions {
  optional FieldOptions options = 50000;
}

I've read some of the other posts on this topic and as far as I can tell I'm 
compiling from the same base as I'm using the maven-protoc-plugin. Plugin 
config:
<plugin>
    <groupId>com.google.protobuf.tools</groupId>
    <artifactId>maven-protoc-plugin</artifactId>
    <version>0.1.9</version>
    <configuration>
        <additionalProtoPathElements>
            <!-- The location of descriptors.proto -->
            
<additionalProtoPathElement>src/includes/proto</additionalProtoPathElement>
        </additionalProtoPathElements>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

I have another proto file that also imports descriptor.proto and a third 
testing proto file that does not. I get the same error from the one that 
imports descriptor.proto, but not the testing one that does not. I'm 
guessing that this is related to the way that the protoc plugin handles 
this, but I don't know how to fix this.

This is loosely related to my other post (
https://groups.google.com/d/topic/protobuf/70NfYyQwnC4/discussion) but 
seemed unrelated enough to warrant another thread.

Any help is appreciated.
-Nik

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/protobuf/-/A-333HnVLu8J.
To post to this group, send email to protobuf@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