Here is my accounts.protobuf
file
package com.lyngo.account.protobuf;
syntax = "proto3";
import "google/protobuf/empty.proto";
service GrpcAccountService {
rpc loginWithEmailPassword(EmailPasswordAuthentication) returns (google.protobuf.Empty);
message EmailPasswordAuthentication {
required string email = 1;
required string password = 2;
}
Here is error after trying to generate the class from protobuf file
[ERROR] PROTOC FAILED: accounts.proto:3:1: Expected top-level statement (e.g. "message").
[ERROR] E:\Programming\1 book-store\account-service\src\main\proto\accounts.proto [0:0]: accounts.proto:3:1: Expected top-level statement (e.g. "message").
After searching, I see that error will appear if I declare the message in a wrong way. But it points to the line where I declare the protobuf syntax version.
Here are some dependencies and plugins in case you need it:
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-server-spring-boot-starter</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.70.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.70.0</version>
</dependency>
<plugin>
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-java</artifactId>
<version>1.70.0</version>
</plugin>
<plugin>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<version>4.29.3</version>
</plugin>
<plugin>
<groupId>.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:4.29.3:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.70.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
Could you please help me to find a solution for this?
Here is my accounts.protobuf
file
package com.lyngo.account.protobuf;
syntax = "proto3";
import "google/protobuf/empty.proto";
service GrpcAccountService {
rpc loginWithEmailPassword(EmailPasswordAuthentication) returns (google.protobuf.Empty);
message EmailPasswordAuthentication {
required string email = 1;
required string password = 2;
}
Here is error after trying to generate the class from protobuf file
[ERROR] PROTOC FAILED: accounts.proto:3:1: Expected top-level statement (e.g. "message").
[ERROR] E:\Programming\1 book-store\account-service\src\main\proto\accounts.proto [0:0]: accounts.proto:3:1: Expected top-level statement (e.g. "message").
After searching, I see that error will appear if I declare the message in a wrong way. But it points to the line where I declare the protobuf syntax version.
Here are some dependencies and plugins in case you need it:
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-server-spring-boot-starter</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.70.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.70.0</version>
</dependency>
<plugin>
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-java</artifactId>
<version>1.70.0</version>
</plugin>
<plugin>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<version>4.29.3</version>
</plugin>
<plugin>
<groupId>.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:4.29.3:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.70.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
Could you please help me to find a solution for this?
Share Improve this question edited 11 hours ago Ly Ngo asked 11 hours ago Ly NgoLy Ngo 12 bronze badges New contributor Ly Ngo is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 0Try:
package com.lyngo.account.protobuf;
import "google/protobuf/empty.proto";
service GrpcAccountService {
rpc loginWithEmailPassword(EmailPasswordAuthentication) returns (google.protobuf.Empty);
}
message EmailPasswordAuthentication {
required string email = 1;
required string password = 2;
}
The schema is well-documented on Protobuf.
syntax
(if used) must be the first statement.
required
is permitted with syntax = "proto2";
and the new editions