Configuring Objectify When Running Applications Locally

Objectify is a third-party library for interfacing with Datastore from Java applications. Cloud Tools for Eclipse allows users to add Objectify, as well as other Google Cloud libraries, to their projects.

This document describes how to configure Cloud Tools for Eclipse to use Objectify when running your application locally.

Configuring Eclipse

To configure Cloud Tools for Eclipse to use Objectify:

  1. In Eclipse, select Run > Run Configurations.

  2. In the Run Configurations dialog, select an existing App Engine Local Server launch configuration, or click the New launch configuration button to create one.

  3. Select the Cloud Platform tab of your run configuration.

  4. Select an account.

  5. Select a project to assign a project ID to be used in the local run. It doesn't matter which project you select because you won't actually connect to it.

    1. As an alternative, if you aren't logged in or don't have a Cloud Project, you can instead set the GOOGLE_CLOUD_PROJECT environment variable to a legal string, such as MyProjectId, in the Environment tab of the run configuration.

Switching Datastore emulator

Objectify 6 may have an issue working with the bundled datastore emulator in the dev_appserver, but it does work with the beta gcloud-based datastore emulator.

To use the gcloud-based emulator:

  1. Launch a terminal and run:

    gcloud beta emulators datastore start
  2. As the emulator starts up, a message displays, similar to this one:

    [datastore] API endpoint: http://localhost:8081  
    [datastore] If you are using a library that supports the DATASTORE_EMULATOR_HOST environment variable, run:  
    [datastore]   export DATASTORE_EMULATOR_HOST=localhost:8081  
    [datastore] Dev App Server is now running.  
  3. In Eclipse, add the DATASTORE_EMULATOR_HOST environment variable to your run configuration in the Environment tab.

    1. In this example, set the name to DATASTORE_EMULATOR_HOST and the value to localhost:8081.

    If you use the gcloud-based datastore emulator, you won't find any data on the Datastore admin page for the local dev_appserver.

What's next