Giter Site home page Giter Site logo

appengine-java-vm-guestbook-extras's Introduction

status: inactive

This project is no longer actively developed or maintained. Managed VMs have become App Engine Flexible.

For new work on App Engine Flexible look at https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/flexible

Java Managed VMs Tutorial

The App Engine Managed VMs hosting environment lets you run App Engine applications on configurable Compute Engine Virtual Machines (VMs). This VM-based hosting environment offers more flexibility and provides more CPU and memory options. Applications that run on Managed VMs are not subject to Java and Python runtime restrictions, and they have access to all the Compute Engine machine types. You can also add third-party libraries and frameworks to your application. Managed VMs instances are Docker-container-based, and with the Beta gcloud SDK, it is now possible to edit the Dockerfile configuration used by a module's instances.

This tutorial walks through the use of Managed VMs and the new gcloud SDK for a Java Web Application. It shows how you can test Managed VMs locally as well as deploy using the new SDK; and shows how to use a non-default Dockerfile.

The code for this tutorial is here: https://github.com/GoogleCloudPlatform/appengine-java-vm-guestbook-extras. It includes several stages of a sample app.

The first stage of the example shows how you can 'escape the App Engine sandbox' by using some Java libraries that don't run on App Engine. The second stage shows how you can edit a Managed VM module's Dockerfile to further configure its instances. In this case, we'll install a linux utility, and also write to the instances' local filesystem. We will also use the latest Jetty 9.3.2 runtime that needs the Open JDK8 JVM.

Initial Setup

First, complete the following steps:

Gcloud Authentication

Be sure to first authenticate with:

$ gcloud auth login

Install Maven and Git###

This tutorial uses Maven 3.1 or above to build its Java projects, so install Maven as necessary. Be familiar with the Managed VMs Maven specific documentation located at https://cloud.google.com/appengine/docs/java/managed-vms/maven

If you are new to git, please refer to the git documentation.

Grab the Sample Code

Then, grab the starter code that we'll use for this tutorial, from this repo: https://github.com/GoogleCloudPlatform/appengine-java-vm-guestbook-extras.

$ git clone https://github.com/GoogleCloudPlatform/appengine-java-vm-guestbook-extras.git
$ cd stage1

This app uses as its starting point the (familiar to many) App Engine "guestbook" sample, but some extras are added that highlight the capabilities of Managed VMs. Here, we'll assume familiarity with the basic Guestbook app and plunge into the new stuff.

The 2 stages shown in this tutorial are:

Stage Description
stage1 Add a captcha library using AWT to the GuestBook application
stagebis Customize the Dockerfile to install a Linux native package and call it from Java, writing to the local file system and uses Open JDK8

All stages use Maven and Servlet 3.1 features, with Debug enabled, and are executed inside a Docker container on the local development server. The exact same Docker container will be running in production when your deploy your application.

Stage 1-Escape the Sandbox

With Managed VMs, you can run outside the traditional App Engine instance 'sandbox'. In this section of the tutorial, we're going to use the java.awt.* package, which does not run on App Engine's sandboxed instances, to build 'captcha' support for the guestbook app. (In the next section, we'll write to the file system, which also is not supported by a sandboxed instance).

Go to the stage1 directory of the downloaded sample. Take a look at stage1/src/main/webapp/WEB-INF/appengine-web.xml. You'll see that it includes these settings:

<vm>true</vm>
<beta-settings>
    <setting name="java_quickstart" value="true"/>
</beta-settings>
<manual-scaling>
    <instances>1</instances>
</manual-scaling>

This indicates that this app module (the 'default' module, in this case) is a Managed VMs module, and indicates that one instance of this module version should be started.

Notice the java_quickstart setting: it allows you to use some advanced Servlet 3.1 annotations processing developed for the Jetty Web Server. For more details about the java_quickstartfeature, you can see this article: https://webtide.com/jetty-9-quick-start/, or refer to this JavaOne 2014 presentation.

While you're looking at appengine-web.xml, go ahead and change the id to your app id. (This is not necessary for running locally using the development server, but is necessary for deployment).

Before running the app, take a quick look at the stage1/src/main/java/com/google/appengine/demos/guestbook/CaptchaServlet.java servlet, which is new. It uses the java.awt.* package to generate and serve up a 'captcha' image, putting the corresponding 'captcha code' in the Session. This is also a Servlet 3.1 annotated servlet, so no need to define it in the web.xml file.

stage1/src/main/webapp/guestbook.jsp displays the captcha image, and asks the user to type in the code. stage1/src/main/java/com/google/appengine/demos/guestbook/SignGuestbookServlet.java checks the submitted code against the value in the Session, and does not record the comment if the captcha code is incorrect.

Maven Deploy on Save

The Maven project is configured to enable the fast "Deploy on Save" feature that IDEs like NetBeans, Eclipse, Android Studio or Intellij support. The Deploy on Save feature will recompile the Java files in place or update the Web Content, and the Google Cloud SDK will detect the file change and trigger automatically a build of a new Docker container with the updated application, allowing very fast development cycles. This is the preferred way of working for productive developers. Some features will not be supported, like for example, when you change some appengine-web.xml or if you add or modify a Servlet 3.1 annotations, but for most changes, it is the fastest way to see them live immediately. The trick for Deploy on Save is in the stage1/pom.xml file, regarding the outputDirectory setup.

<build>
  <!-- needed for enabling compile/reload on save in modern IDEs...-->
  <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes
  </outputDirectory>
 <plugins>
 ...

Run Your Application Locally

First, run the gcloud:run Maven target that will compile your project and start locally the development server and create the correct Docker container to execute your application:

$ mvn gcloud:run

If this does not work, it is possible that you did not install the Cloud SDK or it is not installed in the default location (under you home directory and the google-cloud-sdk/ directory). You can tell Maven a different location by changing the pom.xml and using the gcloud_directory parameter:

   <plugin>
    <groupId>com.google.appengine</groupId>
    <artifactId>gcloud-maven-plugin</artifactId>
    <version>2.0.9.111.v20160527</version>
    <configuration>
      <gcloud_directory>/YOUR/OWN/GCLOUD/INSTALLATION/DIR</gcloud_directory>
      ...

After some initialization steps (validation, build of the Docker image and execution of a Docker container that contains your application)

...
	<<< gcloud-maven-plugin:2.0.9.81.v20151008:run (default-cli) < package @ guestbook-stage1
	
	--- gcloud-maven-plugin:2.0.9.81.v20151008:run (default-cli) @ guestbook-stage1 ---
	
	Running gcloud app run...
	Creating staging directory in: /Users/ludo/appengine-java-vm-guestbook-extras/stage1/target/appengine-staging
	Running appcfg --enable_quickstart --disable_update_check -A notused stage /Users/ludo/appengine-java-vm-guestbook-extras/stage1/target/guestbook-stage1-1.0-SNAPSHOT /Users/ludo/appengine-java-vm-guestbook-extras/stage1/target/appengine-staging
	Reading application configuration data...
	Oct 11, 2015 5:19:28 PM com.google.apphosting.utils.config.IndexesXmlReader readConfigXml
	INFO: Successfully processed /Users/ludo/appengine-java-vm-guestbook-extras/stage1/target/guestbook-stage1-1.0-SNAPSHOT/WEB-INF/datastore-indexes.xml
	
	
	Beginning interaction for module default...
	Success.
	Temporary staging for module default directory left in /Users/ludo/appengine-java-vm-guestbook-extras/stage1/target/appengine-staging
	Running python -S /Users/ludo/google-cloud-sdk/platform/google_appengine/dev_appserver.py --skip_sdk_update_check=true -A app /Users/ludo/appengine-java-vm-guestbook-extras/stage1/target/guestbook-stage1-1.0-SNAPSHOT/app.yaml
	INFO     2015-10-12 00:19:30,519 application_configuration.py:403] No version specified. Generated version id: 20151012t001930
	INFO     2015-10-12 00:19:30,520 devappserver2.py:763] Skipping SDK update check.
	INFO     2015-10-12 00:19:30,567 api_server.py:205] Starting API server at: http://localhost:50916
	INFO     2015-10-12 00:19:30,576 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
	INFO     2015-10-12 00:19:30,584 admin_server.py:116] Starting admin server at: http://localhost:8000
	2015-10-12 00:19:30.888:INFO::main: Logging initialized @293ms
	2015-10-12 00:19:31.056:INFO:oejs.Server:main: jetty-9.2.10.v20150310
	2015-10-12 00:19:31.068:WARN:oejsh.RequestLogHandler:main: !RequestLog
	2015-10-12 00:19:31.070:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/java/lib/jetty-base-sdk/contexts/] at interval 1
	Oct 12, 2015 12:19:31 AM com.google.apphosting.vmruntime.VmMetadataCache getMetadata
	INFO: Meta-data 'attributes/gae_affinity' path retrieval error: metadata
	Oct 12, 2015 12:19:31 AM com.google.apphosting.vmruntime.VmMetadataCache getMetadata
	INFO: Meta-data 'attributes/gae_appengine_hostname' path retrieval error: metadata
	Oct 12, 2015 12:19:31 AM com.google.apphosting.vmruntime.VmMetadataCache getMetadata
	INFO: Meta-data 'attributes/gae_use_nginx_proxy' path retrieval error: metadata
	Oct 12, 2015 12:19:31 AM com.google.apphosting.vmruntime.VmMetadataCache getMetadata
	INFO: Meta-data 'attributes/gae_tmp_force_reuse_api_connection' path retrieval error: metadata
	2015-10-12 00:19:31.625:INFO:oejsh.ContextHandler:main: Started c.g.a.v.j.VmRuntimeWebAppContext@6ce139a4{/,file:/Users/ludo/appengine-java-vm-guestbook-extras/stage1/target/guestbook-stage1-1.0-SNAPSHOT/,AVAILABLE}{/Users/ludo/a/remove/appengine-java-vm-guestbook-extras/stage1/target/guestbook-stage1-1.0-SNAPSHOT}
	2015-10-12 00:19:31.638:INFO:oejs.ServerConnector:main: Started ServerConnector@489115ef{HTTP/1.1}{0.0.0.0:35807}
	INFO     2015-10-12 00:19:32,594 module.py:1735] New instance for module "default" serving on:
http://localhost:8080

you can visit the URL that the development server is running on (likely: http://localhost:8080). You should see a figure that looks like the following. The application is the (probably all-too-familiar) guestbook app, but with a 'captcha' image and field added. You must type in the captcha word correctly for the entry to be posted.

Guestbook with Captcha

Note for IDE users: If you are using NetBeans or Eclipse, you can stop the Cloud SDK run session with a click on the little RED icon that stop a process in the IDE terminal view. There is also a RED icon button in Android Studio and Intellij, but this one will not stop correctly the Cloud SDK: The docker containers will not be stopped and you need to stop them from the command line. You can instead execute the Maven command from CLI or the IDES to safely stop the running processes:

$ mvn gcloud:run_stop

Deploy Your Application

Next, try deploying your application to production.

First, set the project you're using with gcloud:

$ gcloud config set project <your-project>

Make sure that you're using a Managed-VMs-enabled app, in stage1/src/main/webapp/WEB-INF/appengine-web.xml, you have set <vm>true</vm>. Then do:

$ mvn gcloud:deploy

This deployment is using the 'default' Dockerfile, which you can see in the <preview_google-cloud-sdk>/docker/dockerfiles directory. It contains just:

FROM gcr.io/google_appengine/java-compat
ADD . /app

After deployment, go to your app: http://YOUR-APP-ID.appspot.com. The app should work the same as it did with the local development server. This code would not have worked with a 'regular' App Engine instance!

Stage bis-Configure a Dockerfile for the Application

In Stage bis (stage3 directory) of this application, we will upgrade the JVM to Open JDK8 and use the linux 'fortune' program to autofill in the guestbook entries with 'suggested text', in case a guest has a case of writer's block. These changes involve a couple of new things.

First, we need to install the 'fortune' program on our Managed VM instances, so that we can access it. We will do this by defining a Dockerfile for the app. Then, we will define a new class (called stage3/src/main/java/com/google/appengine/demos/guestbook/FortuneInfo.java), that will execute this program, save the results to a new file, then read the file and serve up the results. Take a quick look at FortuneInfo.java. Both the use of ProcessBuilder, and the capability of writing temporary files to the local filesystem, would not work on 'regular' App Engine instances.

Guestbook with Fortunes

Take a look at the stage3/src/main/webapp/Dockerfile file: It looks like this:

 #jetty9-compat is Jetty 9.3.6 and supports only Open JDK8:
 FROM gcr.io/google_appengine/jetty9-compat
 RUN apt-get update && apt-get install -y fortunes

 ADD . /app

The file indicates to: start with the default java8 runtime docker image, and add to it an installation of the 'fortunes' program.

Build your app, via mvn package.

Run Your Application Locally

As described above for Stage 1, build your app and run it locally:

# Via Maven:
$ mvn gcloud:run

You'll see an error:

	  File "/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1026, in main
	    dev_server.start(options)
	  File "/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 818, in start
	    self._dispatcher.start(options.api_host, apis.port, request_data)
	  File "/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 194, in start
	    _module.start()
	  File "/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 1554, in start
	    self._add_instance()
	  File "/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 1706, in _add_instance
	    expect_ready_request=True)
	  File "/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/custom_runtime.py", line 73, in new_instance
	    assert self._runtime_config_getter().custom_config.custom_entrypoint
	  File "/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 382, in _get_runtime_config
	    raise ValueError('The --custom_entrypoint flag must be set for '
	ValueError: The --custom_entrypoint flag must be set for custom runtimes

You can also specify a custom_entrypoint in your project pom.xml. This is an executable that the Cloud SDK will run to start your application locally. If you want to use the Cloud SDK bundled Jetty9 Web Server, you can define this entry point:

      <custom_entrypoint>java
        -Dgcloud.java.application=/Users/ludo/appengine-java-vm-guestbook-extras/stage3/target/guestbook-stage3-1.0-SNAPSHOT
        -Djetty.home=/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/java/lib/java-managed-vm/appengine-java-vmruntime
        -Djetty.base=/Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/java/lib/jetty-base-sdk
        -Dcom.google.apphosting.vmruntime.VmRuntimeFileLogHandler.pattern=/SOMEWRITABLEDIR/log.%g
        -jar 
        /Users/ludo/google-cloud-sdk/platform/google_appengine/google/appengine/tools/java/lib/java-managed-vm/appengine-java-vmruntime/start.jar
        -module=http
        jetty.port={port}
      </custom_entrypoint>

Please make sure you replace the hard coded paths to your Maven project location for the gcloud.java.application property as well as the Cloud SDK location that contains the jetty.home and jetty.base directories.

The {port} value is automatically set by the Cloud SDK to the correct port Jetty should be listening to. This custom entry point basically tells the Cloud SDK to execute the Java Jett9 process witht the correct settings and with your exploded WAR directory located in the target/guestbook-stage3-1.0-SNAPSHOT directory.

You can of course put in the custom_entrypoint any process that would fit your custom execution environment.

Deploy Your App

Deploy your application using the same instructions as above for the Stage 1 version of the app:

# Via Maven:
$ mvn gcloud:deploy

Summary

This tutorial walked through use of Managed VMs and the new gcloud SDK for a Java app, based on an extended version of the "guestbook" app. It showed how you can test Managed VMs locally, as well as deploy using the new SDK; and showed how to "escape the sandbox" and use a non-default Dockerfile.

Contributing changes

Licensing

Copyright (C) 2014-2015 Google Inc.

appengine-java-vm-guestbook-extras's People

Contributors

amygdala avatar dlorenc avatar lesv avatar ludoch avatar v1nay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appengine-java-vm-guestbook-extras's Issues

getting the error No module named googlecloudsdk.core.util when using mvn gcloud:deploy

I follow every steps described in the tutorial. when I try to deploy stage 1 using the command mvn gcloud:deploy I get the error:
No module named googlecloudsdk.core.util.
Is there a way to solve this problem ?

Here is the complete log:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building guestbook-stage1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> gcloud-maven-plugin:2.0.9.81.v20151008:deploy (default-cli) > package @ guestbook-stage1 >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ guestbook-stage1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Owner\Documents\code\git\google\stage1\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ guestbook-stage1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ guestbook-stage1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Owner\Documents\code\git\google\stage1\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ guestbook-stage1 ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ guestbook-stage1 ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ guestbook-stage1 ---
[INFO] Packaging webapp
[INFO] Assembling webapp [guestbook-stage1] in [C:\Users\Owner\Documents\code\git\google\stage1\target\guestbook-stage1-1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Owner\Documents\code\git\google\stage1\src\main\webapp]
[INFO] Webapp assembled in [145 msecs]
[INFO] Building war: C:\Users\Owner\Documents\code\git\google\stage1\target\guestbook-stage1-1.0-SNAPSHOT.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] <<< gcloud-maven-plugin:2.0.9.81.v20151008:deploy (default-cli) < package @ guestbook-stage1 <<<
[INFO]
[INFO] --- gcloud-maven-plugin:2.0.9.81.v20151008:deploy (default-cli) @ guestbook-stage1 ---
[INFO] Creating staging directory in: C:\Users\Owner\Documents\code\git\google\stage1\target\appengine-staging
[INFO] Running appcfg --enable_quickstart --disable_update_check -A notused stage C:\Users\Owner\Documents\code\git\google\stage1\target/guestbook-stage1-1.0-SNAPSHOT C:\Users\Owner\Documents\code\git\google\stage1\target\appengine-staging
Reading application configuration data...

Beginning interaction for module default...
Success.
Temporary staging for module default directory left in C:\Users\Owner\Documents\code\git\google\stage1\target\appengine-staging
[INFO] Running gcloud app deploy...
[INFO] Running python.exe -S C:/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/lib/googlecloudsdk/gcloud/gcloud.py --quiet preview app deploy C:\Users\Owner\Documents\code\git\google\stage1\target\appengine-staging/app.yaml C:\Users\Owner\Documents\code\git\google\stage1\target\appengine-staging/index.yaml
[INFO] Traceback (most recent call last):
[INFO] File "C:/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/lib/googlecloudsdk/gcloud/gcloud.py", line 80, in
[INFO] _DoStartupChecks()
[INFO] File "C:/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/lib/googlecloudsdk/gcloud/gcloud.py", line 72, in _DoStartupChecks
[INFO] from googlecloudsdk.core.util import platforms
[INFO] ImportError: No module named googlecloudsdk.core.util
[ERROR] Error: gcloud app command with exit code : 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.984 s
[INFO] Finished at: 2015-10-29T23:24:50-04:00
[INFO] Final Memory: 16M/222M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.appengine:gcloud-maven-plugin:2.0.9.81.v20151008:deploy (default-cli) on project guestbook-stage1: Error: gcloud app command exit code is: 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@ludoch

gcloud needs better error reporting

The Maven gcloud plugin needs better error reporting. No matter how I configure my software stack, mvn gcloud:run reports:

INFO: Successfully processed /Users/apennebaker/Desktop/src/users-ws/users-impl/target/users-impl-1.22.0-SNAPSHOT/WEB-INF/appengine-web.xml
[ERROR] Error: gcloud app xxx exit code is: 1

mvn -X doesn't give any more detail.

Error pulling google/appengine-java: 404 Client Error: Not Found

I'm quite new to Docker but I'm struggling to create the Container in local (and server) because I can't find a way to get the google/appengine-java image. Here's the error when I launch mvn gcloud:run :

[INFO] Running gcloud app run...
[INFO] Running python -S /Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/gcloud/gcloud.py --project=test-managed-vm preview app run /Users/etienne/DEV/GIT/various/appengine-java-vm-guestbook-extras/stage1/target/guestbook-stage1-1.0-SNAPSHOT
[INFO] Java module found in [/Users/etienne/DEV/GIT/various/appengine-java-vm-guestbook-extras/stage1/target/guestbook-stage1-1.0-SNAPSHOT]
[INFO] INFO: Looking for the Dockerfile in /Users/etienne/DEV/GIT/various/appengine-java-vm-guestbook-extras/stage1/target/guestbook-stage1-1.0-SNAPSHOT
[INFO] INFO: Using Dockerfile found in /Users/etienne/DEV/GIT/various/appengine-java-vm-guestbook-extras/stage1/target/guestbook-stage1-1.0-SNAPSHOT
[INFO] INFO: Looking for image_id for image with tag google/docker-registry
[INFO] INFO: Refreshing access_token
[INFO] INFO: Building image gcloud-credentials-image...
[INFO] INFO: Image gcloud-credentials-image built, id = f6a4c85945ff
[INFO] INFO: Creating container...
[INFO] INFO: Container 1fdd7e4d8702c77fa29be06b8e833b5372361f0981d97fbad0539146500444e5 created.
[INFO] INFO: Looking for image_id for image with tag google/docker-registry
[INFO] INFO: Creating container...
[INFO] INFO: Container 270136d8f34e7c0aacb0889d4de32ab64a1b6ef1f76d01f380273451762bc1c8 created.
[INFO] INFO: Trying to connect to http://192.168.59.103:49157/v1/_ping...
[INFO] Pulling image: google/appengine-java
[INFO] INFO: Pulling image google/appengine-java:latest from Google Cloud Storage...
[INFO] Traceback (most recent call last):
[INFO]   File "/Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/gcloud/gcloud.py", line 170, in <module>
[INFO]     main()
[INFO]   File "/Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/gcloud/gcloud.py", line 166, in main
[INFO]     _cli.Execute()
[INFO]   File "/Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 385, in Execute
[INFO]     post_run_hooks=self.__post_run_hooks, kwargs=kwargs)
[INFO]   File "/Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/calliope/frontend.py", line 274, in _Execute
[INFO]     pre_run_hooks=pre_run_hooks, post_run_hooks=post_run_hooks)
[INFO]   File "/Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 928, in Run
[INFO]     result = command_instance.Run(args)
[INFO]   File "/Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/calliope/exceptions.py", line 78, in TryFunc
[INFO]     return func(*args, **kwargs)
[INFO]   File "/Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/run.py", line 349, in Run
[INFO]     util.MaybePullImage(docker_client, module.runtime)
[INFO]   File "/Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/appengine/lib/images/util.py", line 205, in MaybePullImage
[INFO]     config.DOCKER_BASE_IMAGE_BUCKET)
[INFO]   File "/Users/etienne/DEV/google-cloud-sdk/lib/googlecloudsdk/appengine/lib/images/util.py", line 232, in PullSpecifiedImages
[INFO]     'Error pulling {image}: {e}'.format(image=image_name, e=e))
[INFO] googlecloudsdk.appengine.lib.images.util.DockerPullError: Error pulling google/appengine-java: 404 Client Error: Not Found ("No such id: localhost:49157/google/appengine-java")
[ERROR] Error: gcloud app xxx exit code is: 1

How can I get the google/appengine-java image? I didn't find it on Docker hub registry. The only one I found is https://registry.hub.docker.com/u/google/cloud-sdk/

I tried to pull it : docker pull google/cloud-sdk and also docker pull google/docker-registry
It worked perfectly, but when I try :

MBP-de-Etienne:boot2docker etienne$ docker pull google/appengine-java
Pulling repository google/appengine-java
2014/11/24 15:00:33 Error: image google/appengine-java not found

Am I missing something?
Thanks,

Add Common Problems to README

It can be helpful if common problems users may encounter are included in the readme (like having to run $ gcloud components update app-engine-java first).

My gotcha was when I tried to adapt an existing appengine project to use managed vms, and my pom lacked <packaging>war</packaging>. It spit out:

Error Response: [400] β€œenv” setting is not supported for this deployment

Took me a while commenting out giant swaths of my app to finally notice the difference.

Cheers.

Error A full JDK (not just JRE) is required

I am run stage2 folder use app engine SDK version 1.9.17a

run mvn gcloud:run

HTTP ERROR: 500

Problem accessing /guestbook.jsp. Reason:
    org.apache.jasper.JasperException: PWC6345: There is an error in invoking javac.  A full JDK (not just JRE) is required
Powered by Jetty://

Not starting

Can't seem to build the project as-is. I configured gcloud_directory and even tried the gcloud maven plugin v20160810. I've tried both providing and not providing app.yaml.

I imagine I'm missing something. Any tips/pointers?

This is what I'm seeing:

[INFO] Webapp assembled in [101 msecs]
[INFO] Building war: /Users/wendel.schultz/development/dietsoda/google-solutions/asset-profiler/default/target/guestbook-stage3-1.0-SNAPSHOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] 
[INFO] <<< gcloud-maven-plugin:2.0.9.120.v20160803:run (default-cli) < package @ guestbook-stage3 <<<
[INFO] 
[INFO] --- gcloud-maven-plugin:2.0.9.120.v20160803:run (default-cli) @ guestbook-stage3 ---
[INFO] 
[INFO] Running gcloud app run...
[INFO] Running python -S /usr/local/installs/google-cloud-sdk/platform/google_appengine/dev_appserver.py --skip_sdk_update_check=true -A app /Users/wendel.schultz/development/dietsoda/google-solutions/asset-profiler/default/target/guestbook-stage3-1.0-SNAPSHOT/app.yaml
[INFO] INFO     2016-08-14 06:04:17,968 application_configuration.py:431] No version specified. Generated version id: 20160814t060417
[INFO] Traceback (most recent call last):
[INFO]   File "/usr/local/installs/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 84, in <module>
[INFO]     _run_file(__file__, globals())
[INFO]   File "/usr/local/installs/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 80, in _run_file
[INFO]     execfile(_PATHS.script_file(script_name), globals_)
[INFO]   File "/usr/local/installs/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1040, in <module>
[INFO]     main()
[INFO]   File "/usr/local/installs/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1033, in main
[INFO]     dev_server.start(options)
[INFO]   File "/usr/local/installs/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 758, in start
[INFO]     options.config_paths, options.app_id)
[INFO]   File "/usr/local/installs/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 831, in __init__
[INFO]     module_configuration = ModuleConfiguration(config_path, app_id)
[INFO]   File "/usr/local/installs/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 152, in __init__
[INFO]     'When there is a Dockerfile in the current directory, the only '
[INFO] google.appengine.tools.devappserver2.errors.DockerfileError: When there is a Dockerfile in the current directory, the only supported runtime is runtime: custom.  Please switch to runtime: custom.  The devappserver does not actually use your Dockerfile, so please use either the --runtime flag to specify the runtime you want or use the --custom_entrypoint flag to describe how to start your application.
[ERROR] Error: gcloud app command with exit code : 1
Exception in thread "standard-out-redirection-devappserver" [ERROR] 
java.lang.RuntimeException: The Java Dev Server has stopped.org.apache.maven.plugin.MojoExecutionException: Error: gcloud app command exit code is: 1
    at com.google.appengine.gcloudapp.AbstractGcloudMojo$1.run(AbstractGcloudMojo.java:417)
    at com.google.appengine.gcloudapp.AbstractGcloudMojo.startCommand(AbstractGcloudMojo.java:451)
    at com.google.appengine.gcloudapp.GCloudAppRun.execute(GCloudAppRun.java:280)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)

Environment:

  • Python v 2.7.9
wendelsmbp2:stage3 wendel.schultz$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T09:41:47-07:00)
Maven home: /usr/local/installs/maven/current
Java version: 1.8.0_40, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.3", arch: "x86_64", family: "mac"
wendelsmbp2:default wendel.schultz$
wendelsmbp2:default wendel.schultz$ gcloud components update app-engine-java
You have specified individual components to update.  If you are trying
 to install new components, use:
  $ gcloud components install app-engine-java
Do you want to run install instead (y/N)?  y

All components are up to date.
wendelsmbp2:default wendel.schultz$

google/appengine-java cannot be found

When attempting to use a dockerfile that starts with FROM google/appengine-java as shown in https://github.com/GoogleCloudPlatform/appengine-java-vm-guestbook-extras/blob/master/stage3/src/main/webapp/Dockerfile, the response is

ERROR: Error building docker image play-managed-vm.default.1
ERROR: {"status":"Pulling repository google/appengine-java"}
ERROR: {"errorDetail":{"message":"HTTP code: 404"},"error":"HTTP code: 404"}
ERROR: Internal error while starting instance.

README is out of date

The README says "mvn gcloud:run" will create the correct Docker container to execute the application. This is no longer the case - it just runs in the current environment with dev_appserver.

Can't get the container image

No matter what I do, I always get the following error:

"google.appengine.tools.docker.containers.ImageError: Image with tag localhost:49154/google/appengine-java was not found"

docker version
Client version: 1.4.1
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): 5bc2ff8
OS/Arch (client): darwin/amd64
Server version: 1.4.1
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): 5bc2ff8

boot2docker version
Boot2Docker-cli version: v1.4.1
Git commit: 43241cb

Error 404 after deploying

After deploying to productive I get error 404 "Problem accessing /. Reason: /guestbook.jsp". Everything is working fine in the local docker environment.

  • I follow exactly the instructions
  • I see the application deployed and VM instances in the cloud console
  • the health status changes from UNHEALTHY to OK status
  • billing is enabled and I have enough quota

Any ideas?

Update now that boot2docker is deprecated?

This needs an update because boot2docker is no longer supported by the docker team. Tried with "docker-machine start" syntax but something is broken. I'd actually prefer not to have Maven to all kinds of magic for me. I'm anxious to use compute / managed vm capabilities in the Google Cloud offering.

stage 1 is not working with google SDK

I'm following the tutorial, I'm trying to run the guestbook app locally using the command
$ mvn gcloud:run . When I use this command, it gave me an error which is:
can't open file 'C:/Users/Owner/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/dev_appserver.py': [Errno 2] No such file or directory

When I check in the google Sdk directory I didn't see this file. Is there a way to solve this problem or another way to run the app locally ?

Dockerfile publicly exposed

Since the Dockerfile is placed in src/main/webapp/Dockerfile it is publicly available over http. I imagine this was done to simplify the build process, but it seems like a security issue to me.

Support for Homebrew Python v2.7

When I have Python 2.7 installed via Homebrew, mvn gcloud:run stalls indefinitely, without any error messages.

I'm able to workaround this with brew uninstall python, but I would like to be able to have both gcloud and Python installed at the same time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.