Search code examples
thrift

Thrift include: Type has not been defined


I have a two thrift files: common.thrift, proto.thrift

content:

common.thrift

namespace java ru.domain.myserv.common

struct MyStruct {
    1: i32 val
}

service MyServ {
    1: MyStruct myStruct,
    2: i32 val
}

proto.thrift

include "common.thrift"

namespace java ru.domain.myserv.proto

typedef ru.domain.myserv.common.MyServ MyServ

struct ProtoServ {
    1: MyServ myServ
}

Next, I run the thrift generator:

thrift -r -out ../java --gen java proto.thrift

And I see an errors in console:

[ERROR:/path/proto.thrift:8] (last token was 'ru.domain.myserv.common.MyServ') Type "ru.domain.myserv.common.MyServ" has not been defined.

What I'm doing wrong?


Solution

  • Oh my God.

    I had to specify

    typedef common.MyServ MyServ

    instead of

    typedef ru.domain.myserv.common.MyServ MyServ

    But for what then namesapace is necessary?