Re: [maven-and-scala] Error when compile a Probuf generated java file

25 views
Skip to first unread message

David Bernard

unread,
Mar 28, 2013, 3:43:58 AM3/28/13
to Maven and Scala
Do you have several Builder class into your project ?
Can you share the code of generated myResponseProtocol.java and ServiceStats ?



On Thu, Mar 28, 2013 at 8:19 AM, mmLiu <diveinto...@gmail.com> wrote:
In my project, I have code both in Java and Scala.

while when I try to package my project(using twitter's sbt-package-dist ), Error occurred:

[error] /path/to/my/project/src/main/java/com/mycompany/dp/my/protocol/myResponseProtocol.java:458: reference to Builder is ambiguous;
[error] it is both defined in object myResponse and imported subsequently by
[error] import ServiceStats._
[error]       public Builder newBuilderForType() { return newBuilder(); }
[error]              ^
[error] /path/to/my/project/src/main/java/com/mycompany/dp/my/protocol/myResponseProtocol.java:462: reference to Builder is ambiguous;
[error] it is both defined in object myResponse and imported subsequently by
[error] import ServiceStats._
[error]       public Builder toBuilder() { return newBuilder(this); }
[error]              ^
[error] /path/to/my/project/src/main/java/com/mycompany/dp/my/protocol/myRequestProtocol.java:321: reference to Builder is ambiguous;
[error] it is both defined in object myRequest and imported subsequently by
[error] import RawDeviceInfo._
[error]       public Builder newBuilderForType() { return newBuilder(); }
[error]              ^
[error] /path/to/my/project/src/main/java/com/mycompany/dp/my/protocol/myRequestProtocol.java:325: reference to Builder is ambiguous;
[error] it is both defined in object myRequest and imported subsequently by
[error] import RawDeviceInfo._
[error]       public Builder toBuilder() { return newBuilder(this); }
[error]              ^

myResponseProtocol.java and myRequestProtocol.java are java classes generated using Probuf, the .probuf file looks like this(quit normal):

package com.umeng.dp.my.protocol;
// FATAL: This name works as a version number
// Increase this number everytime you do a non-compatible modification!!
// The block storage writer is responsible for write the version number.
option java_outer_classname = "myResponseProtocol";
message myResponse {
    optional uint64 request_id = 1;
    optional string my = 2;
    enum StatusCode {
        NORMAL = 0;
        DB_FAIL = 1;
        INVALID = 2;
    }
    optional StatusCode status_code = 3;
    optional string error_message = 4;
    enum mySource {
        FID = 0;
        ...
    }
    optional mySource my_source = 5;
    message ServiceStats {
        optional uint32 db_latency_avg = 1;
        optional uint32 db_latency_max = 2;
        ...
        ...
    }
    optional ServiceStats service_stats = 6;


Any idea why this error happens?

ps. I search the web and find this email in this group: "ambiguous class errors when compiling a Maven project", seems we got the same issue,while no solution is provided in that thread. I
have checked the class file generated by Probuf, no  import ServiceStats._ or import ServiceStats.* shown up.


--
 
---
You received this message because you are subscribed to the Google Groups "Maven and Scala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-and-sca...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages