Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java-11 spring-boot deployment to google cloud error: app does not satisfy requirements for [java11]

I am working on a group project where we want to deploy a backend to Google Cloud. The backend is created with Java11, Gradle, and Spring-Boot, and deployed through GitHub with Travis to Google Cloud.

The backend runs as it should at localhost with ./gradlew bootrun, but when trying to deploy it to Google Cloud we get the following error:

ERROR: (gcloud.app.deploy) Your application does not satisfy all of the requirements for a runtime of type [java11]. Please correct the errors and try again.

Java11 error from the terminal

We recreated this error with the following procedure, removing GitHub and Travis from the equation:

Created a new Spring-Boot project at https://start.spring.io/ with these settings:

  • Project: Gradle Project
  • Language: Java
  • Spring Boot: 2.1.9
  • Project Metadata: Options: Java: 11
  • Dependencies: Spring Security, Spring Web, GCP Support

Once created, we added the files app.yaml and client_secret.json.

The client_secret.json file contains information about a test-client at gcloud with a lot of permissions.

app.yaml:

runtime: java11
env: flex

service: default

handlers:
- url: /.*
  script: this field is required, but ignored

Both app.yaml and client_secret.json are stored at the same place build.gradle and settings.gradle are.

Then, from the terminal (we used the one in VScode), we ran gcloud app deploy. This command first asks us if we want to deploy the backend to a specified google cloud project, listing that it found the app.yaml file, the source, and the target. Then, when we pressed Y to continue, the error appears.

Here is the build.gradle file, which might be useful(?):

plugins {
    id 'org.springframework.boot' version '2.1.9.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

ext {
    set('springCloudVersion', "Greenwich.SR3")
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.cloud:spring-cloud-gcp-starter'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.security:spring-security-test'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

So our question is; what does the error mean? And how do we fix it? We have tried a lot of things like editing both app.yaml and build.gradle, but nothing seems to work. We also struggle to understand where the error occurs, because the backend runs fine at localhost.

We appreciate every response!

Best regards HaavardG :D

like image 883
HaavardG Avatar asked Oct 22 '19 13:10

HaavardG


1 Answers

Seems like removing env: flex from app.yaml did the trick as env: flex is somehow not supported by Java11.

I believe...

like image 73
HaavardG Avatar answered Oct 01 '22 02:10

HaavardG