Helidon Application on Google App Engine

Suren K
TechInPieces
Published in
4 min readMay 21, 2020

This article details building an example Java web application using Helidon MP libraries and deploying it on Google App Engine.

Part 1 : Build a new Helidon MP Project

Prerequisites

  1. Java SDK — Used OpenJDK 11 for this example
  2. Apache Maven — Used 3.6.3 for this example
  3. Google Cloud SDK
  4. Account on Google Cloud Platform

Step 1 — Build a new Helidon MP Project

mvn archetype:generate -DinteractiveMode=false \
-DarchetypeGroupId=io.helidon.archetypes \
-DarchetypeArtifactId=helidon-quickstart-mp \
-DarchetypeVersion=2.0.0-M3 \
-DgroupId=io.helidon.examples \
-DartifactId=helidon-mp-gae-greet \
-Dpackage=io.helidon.examples.quickstart.mp

Anatomy of Folder Structure (listing only important files/folder):

helidon-mp-gae-greet
|_README.md
|_app.yaml
|_pom.xml [primary maven build file]
|_src
|_main
| |_java/io/helidon/examples/quickstart/mp
| |_GreetingProvider.java
| |_GreetingResource.java [JAX-RS resource with api paths]
| |_package-info.java [list java packages used in the project]
| |_resources
| |_META-INF
| |_microprofile-config.properties [to manage IP and PORT]
| |_logging.properties [manage logs settings]
|_test

Step 2 — Build

The above command creates a Helidon MP example project with necessary boilerplate code.

$ cd helidon-mp-gae-greet/$ mvn clean package

Tip: Maven creates/uses target folder to deploy compiled sources. Using clean option, deletes the target folder and recreates.

Step 3 — Test/run

$ java -jar ./target/helidon-mp-gae-greet.jar[The last line should show something like this..]2020.05.21 12:09:35 INFO io.helidon.microprofile.server.ServerCdiExtension Thread[main,5,main]: Server started on http://localhost:8080 (and all other host addresses) in 2647 milliseconds (since JVM startup).

Open a new browser tab and http://localhost:8080/greet (i’m using a different port). You may see a message “No handler found for path: /” if you go to http://localhost:8080 , which is okay. we have not defined that.

Sample page for ‘greet’ resource

Part 2 : Preparing for Google App Engine

All about Google App Engine for Java. They support a Java 8 and Java 11 runtimes. I think Helidon app runs only on Java 11 runtime (i haven’t tried it on Java 8 runtime).

The primary requirement for the application to be deployed to Google app engine is a yaml file.

1 — Remove the default app.yaml under the project root

2 — Add helidon-mp-app.yaml in a new folder, like gae under src/main

helidon-mp-gae-greet
|_src
|_main
|_app-engine
|_helidon-mp-app.yaml

Add the below to helidon-mp-app.yaml

runtime: java11

3 — Rebuild the project

$ mvn clean package

4 — Setup Google App Engine

I’m using a new Project Helidon-MP-Test on my Google Cloud. Create New App, Choose Java as Language and Standard Environment .

Create new app or can use an existing one.
Choose Java 11 and Standard

5 — Deploy to Google App Engine

Go to your project root and run this command.

Tip: You will need Google Cloud SDK installed on your machine. I’m running this on my Mac. Run gcloud -v to make sure gcloud is installed.

$ gcloud app deploy ./target/helidon-mp-gae-greet.jar

or, if you have multiple projects on Google Cloud account, use:

$ gcloud app deploy ./target/helidon-mp-gae-greet.jar --project=helidon-mp-test

You will see a confirmation..

$ gcloud app deploy ./target/helidon-mp-gae-greet.jar --project=helidon-mp-testServices to deploy:
descriptor: [/Projects/java/helidon/helidon-mp-gae-greet/target/helidon-mp-app.yaml]
source: [/Projects/research/java/helidon/helidon-mp-gae-greet/target]
target project: [helidon-mp-test]
target service: [default]
target version: [20200521t141143]
target url: [https://helidon-mp-test.uc.r.appspot.com]
Do you want to continue (Y/n)?

and

Beginning deployment of service [default]...Created .gcloudignore file. See `gcloud topic gcloudignore` for details.
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 161 files to Google Cloud Storage ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...done.
Setting traffic split for service [default]...done.
Deployed service [default] to [https://helidon-mp-test.uc.r.appspot.com]You can stream logs from the command line by running:
$ gcloud app logs tail -s default
To view your application in the web browser run:
$ gcloud app browse --project=helidon-mp-test

6 — Test

Follow the url that shows up in confirmation https://helidon-mp-test.uc.r.appspot.com/greet

Helidon MP application running on Google App Engine

7 — You may also verify the application on Google App Engine

Verify applications on Google App Engine

Onward

This is jus the starting with a sample example. There is so much scope to extend and work on Helidon, Java and Google App Engine. As Java advancing at a faster rate (Oracle releasing Java every 6 months), there will be so much more to experiment.. iterate and learn. I leave you’ll with this thought!

References

Hope this was helpful. I tried to make this as simple i can (i know most developers like me do not like huge docs). But i’m always opne to learn, adapt and change. Please don’t hesitate to send me updates. Tweet me @surenkonathala

--

--

Suren K
TechInPieces

Software Engineering Manager, Programmer, Architect, Inventor, Speaker and Writer. Works @Capgemini https://surenk.com