Error while importing another proto file

3.6k views Asked by At

I get an error when I try to compile a proto file to convert to .java.
Could you point out what I'm missing ?

protoc --proto_path=src\main\resources\proto --java_out=src\main\java src\main\resources\proto\PayloadProtocol.proto

PayloadProtocol.proto:32:14: "DataContainer" is not defined.
PayloadProtocol.proto: warning: Import BackendCommunicationService.proto but not used.

Payload.proto

import "BackendCommunicationService.proto";
package com.fleetboard.tp.payload.protocol.protobuf;

option java_package = "com.fleetboard.tp.proto.protocol";
message TPMessage {
        required int32 serviceId               = 1;                    // telematic service (TS) id, who owns this message
        required int32 functionId              = 2;                    // function id refers to the Java class for the payload
        optional uint64 requestId              = 3;                    // Identifier to associate the request to a response 
        optional TPPayload payload             = 4;                    // serialized representation of a TP message
        optional uint64 durability             = 5;                    // life time of message - used from backend 
       optional DataContainer dataPayload      = 6;**   
    }

BackendCommunicationService.proto

package com.fleetboard.tp.backend.protobuf;    
option java_package = "com.fleetboard.tp.proto.backend";

    message DataContainer {
        required DeviceApplication application = 1; // The container's recipient (MT) or sender (MO)
        required string fileName = 2;               // File name (no path), length up to 255
        required uint64 fileTime = 3;               // File time as ms since 1970-01-01 00:00 UTC
    }
1

There are 1 answers

0
Marc Gravell On BEST ANSWER

Fully qualify the name in the importing file:

com.fleetboard.tp.backend.protobuf.DataContainer

or

.com.fleetboard.tp.backend.protobuf.DataContainer

(the . ensures it starts at the root)

You could also try using just the disjoint part, but I don't know if it will work:

backend.protobuf.DataContainer

(since both have the com.fleetboard.tp. prefix)