0

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"?>
<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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.publiclibrary</groupId>
    <artifactId>PublicLibrary</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>PublicLibrary</name>
    <description>Demo project for Spring data relationship</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

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

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

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>25.0-jre</version>
        </dependency>

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

I would appreciate any help.

am101
  • 31
  • 2
  • 7
  • 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 – Alex Riquelme Apr 08 '19 at 16:02

2 Answers2

0

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> section it requires <maven.compiler.source> and <maven.compiler.target>:

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

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>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>${appengine.maven.plugin}</version>
  </plugin>
TasosZG
  • 1,274
  • 1
  • 6
  • 13
0

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
am101
  • 31
  • 2
  • 7