Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 809
Venky Avatar asked Jan 05 '17 14:01

Venky


People also ask

What are Google Cloud Endpoints?

Endpoints is an API management system that helps you secure, monitor, analyze, and set quotas on your APIs using the same infrastructure Google uses for its own APIs.

What type of service model is Google Appengine using?

App Engine is a fully managed, serverless platform for developing and hosting web applications at scale. You can choose from several popular languages, libraries, and frameworks to develop your apps, and then let App Engine take care of provisioning servers and scaling your app instances based on demand.


2 Answers

To answer my own question partially : I could finally get the "Echo application" (mentioned in https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java) to work

But I had to make 2 changes: a) Comment out the block in appengine-web.xml . ie,

<!--
<basic-scaling>
  <max-instances>2</max-instances>
</basic-scaling>
-->

After doing this, I got a different error, "failed endpoints-api-configuration: com.google.api.config.ServiceConfigException: Failed to fetch default config version for service" To get around this :

b) Comment out the ServiceManagementConfigFilter from web.xml , ie,

<!--
    <filter>
      <filter-name>endpoints-api-configuration</filter-name>
      <filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
   </filter>
-->
<!--    
<filter-mapping>
    <filter-name>endpoints-api-configuration</filter-name>
    <servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>
-->

After this,

  1. To build : mvn clean package

  2. To run locally : appengine-java-sdk/1.9.44/appengine-java-sdk/appengine-java-sdk-1.9.44/bin/dev_appserver.sh /path/to/war/directory

It would be great if someone could shed more light on implication of these changes, and on how we could get it to work out of the box

like image 107
Venky Avatar answered Oct 13 '22 00:10

Venky


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

like image 36
Þórir Gunnarsson Avatar answered Oct 13 '22 00:10

Þórir Gunnarsson