Skip to content

grpc-java program not found or is not executable #12051

Closed
@ashish20790

Description

@ashish20790

Hello,

I have implemented grpc API's in my spring boot application. I am using Windows machine for development, and everything was working fine on local dev environment but as soon as i tried to make a Docker build of my application i got below error.

* What went wrong:
Execution failed for task ':app:generateProto'.
> protoc: stdout: . stderr: /root/.gradle/caches/modules-2/files-2.1/io.grpc/protoc-gen-grpc-java/1.72.0/41925ea1fd8cf6fb60b42ac277bb4c73476c9a71/protoc-gen-grpc-java-1.72.0-linux-x86_64.exe: program not found or is not executable
  Please specify a program using absolute path or make sure the program is available in your PATH system variable
  --grpc_out: protoc-gen-grpc: Plugin failed with status code 1.

Below are the gradle dependencies and code block in build.gradle file i have defined.

implementation "io.grpc:grpc-netty-shaded:$grpcVersion"
    implementation "io.grpc:grpc-protobuf:$grpcVersion"
    implementation "io.grpc:grpc-stub:$grpcVersion"
    implementation 'net.devh:grpc-server-spring-boot-starter:3.1.0.RELEASE'
    implementation 'net.devh:grpc-client-spring-boot-starter:3.1.0.RELEASE'
    implementation 'com.google.protobuf:protobuf-java:4.30.2'

    annotationProcessor "io.grpc:grpc-stub:$grpcVersion"
    annotationProcessor "io.grpc:grpc-protobuf:$grpcVersion"


protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:4.30.2"
    }
    plugins {
        grpc {
            if (java.util.Objects.nonNull(System.getenv('CODEARTIFACT_REPO_URL'))) {
                //For Docker build https://github.com/grpc/grpc-java/issues/12051
                path = "/usr/bin/protoc-gen-grpc-java"
            } else {
                //For simple gradle build
                artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
            }
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {}
            }
            task.plugins {
                grpc {}
            }
        }
    }

}

Gradle: 8.12
Spring Boot: 3.4.2
Java: 17
grpcVersion: 1.72.0

As a workaround i have defined below piece of highlighted code in my Dockerfile to install grpc-java for my alpine based container, but i noticed that grpc-java was removed from 3.19 onwards version of alpine community.

RUN chmod +x gradlew

**RUN echo "http://dl-cdn.alpinelinux.org/alpine/v3.18/community" >> /etc/apk/repositories && apk update

RUN apk add grpc-java**

# Gradle build without checkstyle and test
RUN ./gradlew -x checkstyleMain -x checkstyleTest -x test --no-daemon  build

Can you please help me here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions