Using google endpoints on AppEngine

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

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

Dependence for the used endpoint library:

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

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

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

New structure 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 cannot start the local dev server, open the API explorer or use the local data store (all this was possible before). Can someone help me with a guide on working with the new infrastructure.

Also, is the former structure obsolete?

+5
java google-app-engine google-cloud-endpoints
source share
2 answers

There are a few problems you encounter, and this material is too sensitive to configuration problems:

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

  • Use the correct Google project identifier when replacing YOUR_PROJECT_ID in pom.xml. It must be a valid project identifier for all steps to work.
  • When replacing YOUR-PROJECT-ID in echo.java

If the project ID is invalid (actually exists in AppEngine), the following steps will not work

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

The quick start guide is not very useful for step 5. Step 4 should end with a successful message.

Finally, the sample comes with the Maven plugin, which 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> 

using:

  <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 does not work is that the devserver target does not exist in the new plugin. The old Maven plugin allows you to run: mvn appengine: devserver

+4
source share

To partially answer my question: I could finally get an โ€œEcho appโ€ (mentioned at https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java ) to work

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

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

After that, I got another error: "failed endpoints-api-configuration: com.google.api.config.ServiceConfigException: Failed to get the default configuration version for the service" To get around this:

b) Comment on ServiceManagementConfigFilter from web.xml, i.e.

 <!-- <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 that

  • To build: mvn clean package

  • 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 the consequences of these changes and on how we could make him work out of the box

+6
source share

All Articles