Google Cloud Platform
Java

Deploying a Java App

This page shows you how to use Maven (recommended) or the appcfg command to deploy your app. The appcfg tool is included with the App Engine Java SDK.

  1. Before you begin
    1. Setting up Maven (recommended)
  2. Uploading an app
    1. Using Maven (recommended)
    2. Using appcfg (alternative)
  3. Updating indexes
  4. What's next

Before you begin

Maven 3.1 or greater is required. Additionally, you must use Java 7. See the reference page for details on initial setup.

Compile and build your project using Maven before following this guide's steps.

Uploading an app

From your project's top level directory, invoke Maven as follows:

mvn appengine:update

You will be prompted for an authorization code in the terminal window and your web browser will launch with a consent screen which you must accept in order to be authorized. Follow the prompts to copy any codes from the browser to the command line.

Using appcfg (alternative)

To upload your application files, run the appcfg command with the update action and the location of your WAR file.

Windows

appengine-java-sdk\bin\appcfg.cmd [options] update <war-location>

Mac / Linux

./appengine-java-sdk/bin/appcfg.sh [options] update <war-location>

If you are using an HTTP proxy, use the --proxy argument to tell appcfg its address. (If you use a different proxy for HTTPS, use the --proxy_https argument also.)

Windows

appengine-java-sdk\bin\appcfg.cmd --proxy=10.1.2.3 update <war-location>

Mac / Linux

./appengine-java-sdk/bin/appcfg.sh --proxy=10.1.2.3 update <war-location>

If this is your first time using the tool, you'll be asked to authorize it through a browser. By default, the token will be stored in the .appcfg_oauth2_tokens_java file in your home directory so you won't be asked again.

The tool will automatically use the application ID from the app.yaml file. However, many of our sample applications omit application: from the app.yaml file, so you will need to specify a Console project ID as the application ID when deploying them:

Windows

appengine-java-sdk\bin\appcfg.cmd -A <YOUR_PROJECT_ID> update <war-location>

Mac / Linux

./appengine-java-sdk/bin/appcfg.sh -A <YOUR_PROJECT_ID> update <war-location>

If your app is factored into more than one Module, you can specify which services should be updated.

  • If you are updating the default service, it must come first in the list.
  • If you are uploading the app for the first time, the default service must be included.

Windows

appengine-java-sdk\bin\appcfg.cmd update <mod1-war-location> <mod2-war-location>

Mac / Linux

./appengine-java-sdk/bin/appcfg.sh update <mod1-war-location> <mod2-war-location>

You will receive verification via the command line as each service is successfully deployed.

Updating indexes

If your app's index.xml file defines an index that doesn't yet exist, App Engine will create it after you upload your app. This process may take a while, and any query that requires the index will raise an exception until the index is built.

To prevent this:

  1. Give the app a new version number in app.yaml.
  2. In the Cloud Platform Console, check the status of the app's indexes.
  3. Once the index has been built, manually update the default version in the Cloud Platform Console.

Alternatively:

  1. Upload the index.xml configuration before uploading the app:

    appcfg.py update_indexes myapp/
    
  2. In the Cloud Platform Console, check the status of the app's indexes.

  3. Once the index has been built, upload your app.

What's next