Search code examples
javagoogle-app-enginegoogle-cloud-endpoints

Using google cloud endpoints on AppEngine


I normally use Google Cloud Endpoints on the AppEngine (Java) , as described in :

https://cloud.google.com/appengine/docs/java/endpoints/helloendpoints-java-maven

The dependency for the endpoints library I use is :

<plugin>
   <groupId>com.google.appengine</groupId>
   <artifactId>appengine-endpoints</artifactId>
   <version>1.9.48</version>
</plugin>

Using this, I can start a local development server using the command: mvn clean package appengine:devserver

However, there seems to be a new version of cloud endpoints. https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java .

The new framework is found here

<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>${endpoints.framework.version}</version>
</dependency>

The same maven commands do not work here. I am unable to start a local dev server, open the API explorer or use a local datastore (all of which was possible earlier) . Could someone please guide me on how to work with the new framework.

Also, is the former framework likely to be deprecated ?


Solution

  • There are a few problems you are running into and this stuff is overly sensitive to configuration issues:

    To solve the problems follow the instructions in: https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java

    1. Use the correct Google project id when you replace the YOUR_PROJECT_ID in pom.xml. It needs to be a valid project id for all the steps to work.
    2. Same when replacing the YOUR-PROJECT-ID in echo.java

    If the project id is not valid (actually exists in AppEngine) the next steps won't work

    1. execute: mvn exec:java -DGetSwaggerDoc
    2. execute: gcloud service-management deploy openapi.json
    3. execute: export ENDPOINTS_SERVICE_NAME=echo-api.endpoints.<your project id>.cloud.goog

    The quickstart guide is not very helpful for step 5. Step 4 needs to end with a success message.

    Finally the sample comes with a Maven plugin that does not seem to work with the new Endpoints. Instead of using:

        <plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>${appengine.maven.plugin.version}</version>
        </plugin>
    

    use:

        <plugin>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>1.9.44</version>
        </plugin>
    

    The answer to the question why mvn appengine:devserver doesn't work is that the devserver target doesn't exist in the new plugin. The old Maven plugin allows you to execute: mvn appengine:devserver