Title: Error when deploy Spring Boot application in Google AppEngine + Non Zero Exit 2
Tags: spring-boot;google-app-engine;google-cloud-platform
Question: I am getting below error when deploying my test maven Spring Boot REST app in GAE - 

[ERROR] Failed to execute goal com.google.cloud.tools:appengine-maven-plugin:2.0.0-rc5:deploy (default-cli) on project PublicLibrary: App Engine application deployment failed: com.google.cloud.tools.appengine.operations.cloudsdk.process.ProcessHandlerException: com.google.cloud.tools.appengine.AppEngineException: Non zero exit: 2 -> [Help 1]

App.yaml looks like 

```runtime: java
env: flex
runtime_config:
  jdk: openjdk8
env_variables:
  SPRING_PROFILES_ACTIVE: "gcp"
handlers:
- url: /.*
  script: this field is required, but ignored
manual_scaling: 
  instances: 1
```

pom.xml 

```<?xml version="1.0" encoding="UTF-8"?&gt;
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    <modelVersion&gt;4.0.0</modelVersion&gt;
    <parent&gt;
        <groupId&gt;org.springframework.boot</groupId&gt;
        <artifactId&gt;spring-boot-starter-parent</artifactId&gt;
        <version&gt;2.1.3.RELEASE</version&gt;
        <relativePath/&gt; <!-- lookup parent from repository --&gt;
    </parent&gt;
    <groupId&gt;com.publiclibrary</groupId&gt;
    <artifactId&gt;PublicLibrary</artifactId&gt;
    <version&gt;0.0.1-SNAPSHOT</version&gt;
    <name&gt;PublicLibrary</name&gt;
    <description&gt;Demo project for Spring data relationship</description&gt;

    <properties&gt;
        <java.version&gt;1.8</java.version&gt;
    </properties&gt;

    <profiles&gt;
        <profile&gt;
            <id&gt;cloud-gcp</id&gt;
            <dependencies&gt;
                <dependency&gt;
                  <groupId&gt;org.springframework.cloud</groupId&gt;
                  <artifactId&gt;spring-cloud-gcp-starter</artifactId&gt;
                  <version&gt;1.0.0.RELEASE</version&gt;
                </dependency&gt;
            </dependencies&gt;
            <build&gt;
              <plugins&gt;
                <plugin&gt;
                    <groupId&gt;com.google.cloud.tools</groupId&gt;
                    <artifactId&gt;appengine-maven-plugin</artifactId&gt;
                    <version&gt;2.0.0-rc5</version&gt;
                    <configuration&gt;
                        <deploy.projectId&gt;libraryapi-03312019</deploy.projectId&gt;
                        <deploy.version&gt;1.0</deploy.version&gt;
                    </configuration&gt;                
                </plugin&gt;
              </plugins&gt;
            </build&gt;            
        </profile&gt;
    </profiles&gt;

    <dependencies&gt;
        <dependency&gt;
            <groupId&gt;org.springframework.boot</groupId&gt;
            <artifactId&gt;spring-boot-starter-actuator</artifactId&gt;
        </dependency&gt;
        <dependency&gt;
            <groupId&gt;org.springframework.boot</groupId&gt;
            <artifactId&gt;spring-boot-starter-data-jpa</artifactId&gt;
        </dependency&gt;
        <dependency&gt;
            <groupId&gt;org.springframework.boot</groupId&gt;
            <artifactId&gt;spring-boot-starter-data-rest</artifactId&gt;
        </dependency&gt;
        <dependency&gt;
            <groupId&gt;org.springframework.boot</groupId&gt;
            <artifactId&gt;spring-boot-starter-validation</artifactId&gt;
        </dependency&gt;
        <dependency&gt;
            <groupId&gt;org.springframework.boot</groupId&gt;
            <artifactId&gt;spring-boot-starter-web</artifactId&gt;
        </dependency&gt;

        <dependency&gt;
            <groupId&gt;com.google.guava</groupId&gt;
            <artifactId&gt;guava</artifactId&gt;
            <version&gt;25.0-jre</version&gt;
        </dependency&gt;

        <dependency&gt;
            <groupId&gt;org.springframework.boot</groupId&gt;
            <artifactId&gt;spring-boot-devtools</artifactId&gt;
            <scope&gt;runtime</scope&gt;
        </dependency&gt;
        <dependency&gt;
            <groupId&gt;com.h2database</groupId&gt;
            <artifactId&gt;h2</artifactId&gt;
            <scope&gt;runtime</scope&gt;
        </dependency&gt;
        <dependency&gt;
            <groupId&gt;org.projectlombok</groupId&gt;
            <artifactId&gt;lombok</artifactId&gt;
            <optional&gt;true</optional&gt;
        </dependency&gt;
        <dependency&gt;
            <groupId&gt;org.springframework.boot</groupId&gt;
            <artifactId&gt;spring-boot-starter-test</artifactId&gt;
            <scope&gt;test</scope&gt;
            <exclusions&gt;
                <exclusion&gt;
                    <groupId&gt;org.assertj</groupId&gt;
                    <artifactId&gt;assertj-core</artifactId&gt;
                </exclusion&gt;
            </exclusions&gt;
        </dependency&gt;
    </dependencies&gt;

    <build&gt;
        <plugins&gt;
            <plugin&gt;
                <groupId&gt;org.springframework.boot</groupId&gt;
                <artifactId&gt;spring-boot-maven-plugin</artifactId&gt;
            </plugin&gt;
        </plugins&gt;
    </build&gt;

</project&gt;

```

I would appreciate any help.

Comment: Can you try to deploy your application using [maven](https://cloud.google.com/appengine/docs/flexible/java/using-maven) instead of an app.yaml? it will be much easier, the command should be like: mvn appengine:deploy


Here is another answer: Thanks.  I followed the sample app and add the differences to my pom.xml.  That alone didn't fix the issue.  Additionally, I added legacy health checks that to app.yaml that allowed to deploy the app (which took quite some time) -
health_check:
  enable_health_check: True
  check_interval_sec: 5
  timeout_sec: 4
  unhealthy_threshold: 2
  healthy_threshold: 2

But after deployment when I try to access the app as https://< project-id>:appspot.com I get below error - 

Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.

UPDATE
I added the resources section to app.yaml as in GAE Java is known to consume high memory as identified in this article

```resources:
  cpu: 2
  memory_gb: 2.3
  disk_size_gb: 10
  volumes:
  - name: ramdisk1
    volume_type: tmpfs
    size_gb: 0.5
```


Here is another answer: Check the official Springboot sample of Google Cloud Platform to see what you might be doing different.

For example, I see that in the <properties&gt; section it requires <maven.compiler.source&gt; and <maven.compiler.target&gt;:

``` <properties&gt;
    <java.version&gt;1.8</java.version&gt;
    <maven.compiler.source&gt;${java.version}</maven.compiler.source&gt; <!-- REQUIRED --&gt;
    <maven.compiler.target&gt;${java.version}</maven.compiler.target&gt; <!-- REQUIRED --&gt;
    <project.build.sourceEncoding&gt;UTF-8</project.build.sourceEncoding&gt;
    <appengine.maven.plugin&gt;1.3.2</appengine.maven.plugin&gt;
  </properties&gt;
```

Note that you are using version 2.0.0-rc5 for the appengine-maven-plugin so if you add it in the properties like above you should use the same version as in the plugin section:

```  <plugin&gt;
    <groupId&gt;com.google.cloud.tools</groupId&gt;
    <artifactId&gt;appengine-maven-plugin</artifactId&gt;
    <version&gt;${appengine.maven.plugin}</version&gt;
  </plugin&gt;
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:03/31/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<spring-boot><google-app-engine><google-cloud-platform>', 'Title': 'Error when deploy Spring Boot application in Google AppEngine + Non Zero Exit 2', 'ViewCount': 2345, 'id': 55445507, 'user_AboutMe': None, 'user_AccountId': 5858857.0, 'user_DisplayName': 'am101', 'user_Reputation': 31.0, 'user_Views': 9.0, 'user_id': 4615269.0}}