Google App Engine 应用程序突然停止工作,返回 503
Google App Engine Application Suddenly Stopped Working, returning 503
我在 Google App Engine 上有一个应用程序 运行,我在 2018 年 9 月 6 日部署了应用程序最新版本的最后一个版本,但今天应用程序停止服务请求,它正在返回错误 503
<HTML>
<HEAD>
<TITLE>Service Unavailable</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Service Unavailable</H1>
<H2>Error 503</H2>
</BODY>
</HTML>
我以为是因为我还没有迁移到已弃用的 Cloud Endpoint v1.1 到 V2.0
但是在我进行了迁移所需的更改之后,当我尝试部署它时仍然 returns 503 而 运行 Maven 命令部署或生成文档。
我知道 Google 表示他们昨天在某些 App Engine 区域遇到了 issues,但我不确定这是否与我所遇到的有任何关系。
我的 App 引擎应用程序正在使用美国中部地区。
更新:看起来云端点 V1.1 已关闭,无法再提供流量,因此按照迁移指南,我已经能够迁移到 2.0 版,但是不幸的是,api-发现文档
出现错误
这是错误
500
API 发现响应缺少必填字段。
我正在努力解决这个问题
这是我的 pom.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>group-id</groupId>
<artifactId>artifact-id</artifactId>
<properties>
<app.id>project-id</app.id>
<app.version>1</app.version>
<appengine.version>1.9.64</appengine.version>
<gcloud.plugin.version>2.0.9.121.v20160815</gcloud.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<jackson.version>2.9.0</jackson.version>
<archiveClasses>true</archiveClasses>
</properties>
<prerequisites>
<maven>3.3.9</maven>
</prerequisites>
<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Objectify library ready -->
<dependency>
<groupId>com.googlecode.objectify</groupId>
<artifactId>objectify</artifactId>
<version>6.0</version>
</dependency>
<!-- Apache Commons Library -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<!-- Add support for joda money library -->
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-money</artifactId>
<version>0.10.0</version>
</dependency>
<!--Added support for joda time library -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
</dependency>
<!-- end joda time api.-->
<!-- Load scrypt library for password encryption and decryption -->
<dependency>
<groupId>com.lambdaworks</groupId>
<artifactId>scrypt</artifactId>
<version>1.4.0</version>
</dependency>
<!-- Objectify utils to help us with currency -->
<dependency>
<groupId>com.sappenin.objectify</groupId>
<artifactId>objectify-utils</artifactId>
<version>5.1.3</version>
</dependency>
<!-- google guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<!-- Apache poi for excel file processing -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<!-- jackson-dataformat-csv-->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-csv</artifactId>
<version>2.7.0</version>
</dependency>
<!-- jackson data bind library for json -->
<!-- Google cloud storage ends -->
<!-- google cloud storage client -->
<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
<version>0.7</version>
<exclusions>
<exclusion>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.23.0</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>2.0.2-beta</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${appengine.version}</version>
<scope>test</scope>
</dependency>
<!-- Mail Dependencies with MailGun -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.19.1</version>
</dependency>
<!-- End Mail Dependencies with MailGun -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker-gae</artifactId>
<version>2.3.25-incubating</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<!-- Note: core-annotations version x.y.0 is generally compatible with
(identical to) version x.y.1, x.y.2, etc. -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application-->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<stage.enableJarClasses>true</stage.enableJarClasses>
<cloudSdkPath>/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk</cloudSdkPath>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<!-- deploy configuration -->
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>endpoints-framework-maven-plugin</artifactId>
<version>1.0.2</version>
<configuration>
<!-- plugin configuration -->
<hostname>project-id.appspot.com</hostname>
</configuration>
<executions>
<execution>
<goals>
<goal>discoveryDocs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
这是我的 web.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Endpoints web.xml -->
<!-- [START web] -->
<servlet>
<display-name>Remote API Servlet</display-name>
<servlet-name>RemoteApiServlet</servlet-name>
<servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Grader</servlet-name>
<servlet-class>com.softquest.apollo.servlets.Grader</servlet-class>
</servlet>
<servlet>
<servlet-name>SheetHandler</servlet-name>
<servlet-class>com.softquest.apollo.servlets.SheetHandler</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RemoteApiServlet</servlet-name>
<url-pattern>/remote_api</url-pattern>
</servlet-mapping>
<!-- Score Sheet Servlet -->
<!-- Remote Api Servlet -->
<servlet>
<servlet-name>EndpointsServlet</servlet-name>
<servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.softquest.apollo.services.UserServices</param-value>
</init-param>
</servlet>
<!-- Payment Response Servlet -->
<servlet>
<servlet-name>PaymentResponseServlet</servlet-name>
<servlet-class>com.softquest.apollo.servlets.PaymentResponseServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PaymentResponseServlet</servlet-name>
<url-pattern>/PaymentResponse</url-pattern>
</servlet-mapping>
<!-- Payment Response Servlet-->
<servlet-mapping>
<servlet-name>EndpointsServlet</servlet-name>
<url-pattern>/_ah/api/*</url-pattern>
</servlet-mapping>
<!-- Objectify filter registration -->
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Setup ServletContextListener to start up objectify entities on application -->
<servlet>
<servlet-name>BackEndStarter</servlet-name>
<servlet-class>com.softquest.apollo.BackEndStarter</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>BackEndStarter</servlet-name>
<url-pattern>/backend/starter</url-pattern>
</servlet-mapping>
<!-- Migration servlet -->
<servlet>
<servlet-name>MigrationServlet</servlet-name>
<servlet-class>com.softquest.apollo.servlets.MigrationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MigrationServlet</servlet-name>
<url-pattern>/migration/*</url-pattern>
</servlet-mapping>
<!-- Migration Servlet-->
<!-- Migration Handler Servlet -->
<servlet>
<servlet-name>MigrationHandler</servlet-name>
<servlet-class>com.softquest.apollo.servlets.MigrationHandler</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MigrationHandler</servlet-name>
<url-pattern>/migration-handler/*</url-pattern>
</servlet-mapping>
<!-- End of Migration handler Servlet-->
<!-- Setup web.xml to start up context listener -->
<servlet-mapping>
<servlet-name>Grader</servlet-name>
<url-pattern>/Grader</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SheetHandler</servlet-name>
<url-pattern>/SheetHandler</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
我在尝试调用 api 发现文档时遇到此错误,我已将其追溯到 [=16= 的第 72 行的空指针错误]
com.google.api.server.spi.EndpointsServlet 文件
if (!dispatcher.dispatch(method, path, context)) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
response.getWriter().append("Not Found");
}
我猜错误是发布到某些第三方库可能仍在使用任何较旧的云端点 Maven 依赖项或插件。所以我会从我的 pom.xml 中删除所有依赖项并尝试部署。
更新:
我能够修复 API 发现错误,它是由与 Google Guava 库有关的反射错误引起的,而迁移文档已经声明版本 19 可以工作,但它没有t,升级到版本 20 及更高版本为我解决了这个问题,现在我在所有端点上都收到错误 404。当我能够解决这个问题时,我会写一个答案。
我在几个月未更改的端点上遇到同样的问题,日志中也没有任何内容。我认为这可能是一个应用程序引擎问题。
编辑
我解决了我们的问题,尽管您提到您已尝试更新到新的 Cloud Endpoint v2.0 但您仍然遇到问题,结果证明我们的项目遵循从 v1.1 到 v1.1 的迁移步骤v2 修复了问题 https://cloud.google.com/endpoints/docs/frameworks/python/migrating.
文档说 v1.1 将在 8 月 2 日关闭,我猜他们刚刚解决了这个问题
经过一系列的点击和试用方法,我已经成功迁移到 Endpoints V2。
在 Android Studio 上开发的 App Engine 项目具有以下结构-
项目
- 应用程序
- 后端
- build.gradle
我必须更改所有 3 个地方 build.gradle。其中 project 是根项目,app 是 android app,backend 是 App Engine app。所有这些都有自己的 build.gradlew.
让我们一一改变。
/app/build.gradle(在 android 客户端中进行更改)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.+'
// Remove this line
//compile project(path: ':micirclews', configuration: 'android-endpoints')
}
在 android 插件
之后应用端点插件
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'
/backend/build.gradle(在 backend/appengine 模块中进行更改)
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
//Remove this
//classpath 'com.google.appengine:gradle-appengine-plugin:1.9.59'
//Add these two lines
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
}
}
删除这个- apply plugin: 'appengine'
加上这两个-
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
dependencies {
//Remove these 3 lines-
//appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.59'
//compile 'com.google.appengine:appengine-endpoints:1.9.59'
//compile 'com.google.appengine:appengine-endpoints-deps:1.9.59'
//Add these 2 lines-
compile 'com.google.endpoints:endpoints-framework:2.0.9'
compile 'javax.inject:javax.inject:1'
.....
}
// delete this whole block, it's configuration for the older plugin
// appengine {
// downloadSdk = true
// appcfg {
// oauth2 = true
// }
// endpoints {
// getClientLibsOnBuild = true
// getDiscoveryDocsOnBuild = true
// }
// }
/build.gradle(在root的build.gradle中进行修改)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
//Add these 2 lines
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
}
}
仔细进行所有更改后,清理项目,重建它并 运行 它。最后在一切正常时部署它。
你可以在这里参考整个过程 -
https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin/blob/master/ANDROID_README.md
正如 saiyr 在评论中所述,Google Cloud Endpoints v1.1 已完全弃用并停止提供流量,这就是我遇到错误的原因。
我通过迁移到云端点 v2 解决了这个问题,这个过程就像遵循 migration docs 中的指南一样简单,但这里有一些我在迁移时遇到的问题以及我如何修复它。
Google guava库必须更新到19以上版本,使用19或更低版本可能会导致应用程序在处理请求时抛出反射错误。
如果您有多个服务 classes,则必须在声明 com.google.api.server.spi.EndpointsServlet
Servlet 时将它们作为服务参数添加到 web.xml 文件中。
由于某些原因,仅列出一项服务 class 在云端点 1.0 Api 中为我工作 Api 为我拥有的所有服务 classes 生成了文档和路由,但没有在 [= =11=] Servlet,我认为它与 Objectify 过滤器有关。 See the Docs for more info
由于 Google App Engine Java 7 运行时也已弃用,我决定迁移到 Java 8 但不幸的是我用来抽象的库连接到数据存储区 (Objectify) 的过程似乎不适用于 Java 8 运行时,我稍后会研究这个问题,但恢复到 Java 7 运行时对我有用并且应用程序已备份并且运行。
更新:我在迁移到 Java 8 运行时时遇到的问题与 Objectify 无关,我用于加密密码的库 (BCrypt) 是问题所在,它只是在 Google App Engine Java 8 运行时不起作用,我不得不切换到 spring 安全性中的加密库。
我在 Google App Engine 上有一个应用程序 运行,我在 2018 年 9 月 6 日部署了应用程序最新版本的最后一个版本,但今天应用程序停止服务请求,它正在返回错误 503
<HTML>
<HEAD>
<TITLE>Service Unavailable</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Service Unavailable</H1>
<H2>Error 503</H2>
</BODY>
</HTML>
我以为是因为我还没有迁移到已弃用的 Cloud Endpoint v1.1 到 V2.0
但是在我进行了迁移所需的更改之后,当我尝试部署它时仍然 returns 503 而 运行 Maven 命令部署或生成文档。
我知道 Google 表示他们昨天在某些 App Engine 区域遇到了 issues,但我不确定这是否与我所遇到的有任何关系。
我的 App 引擎应用程序正在使用美国中部地区。
更新:看起来云端点 V1.1 已关闭,无法再提供流量,因此按照迁移指南,我已经能够迁移到 2.0 版,但是不幸的是,api-发现文档
出现错误这是错误
500
API 发现响应缺少必填字段。
我正在努力解决这个问题
这是我的 pom.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>group-id</groupId>
<artifactId>artifact-id</artifactId>
<properties>
<app.id>project-id</app.id>
<app.version>1</app.version>
<appengine.version>1.9.64</appengine.version>
<gcloud.plugin.version>2.0.9.121.v20160815</gcloud.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<jackson.version>2.9.0</jackson.version>
<archiveClasses>true</archiveClasses>
</properties>
<prerequisites>
<maven>3.3.9</maven>
</prerequisites>
<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Objectify library ready -->
<dependency>
<groupId>com.googlecode.objectify</groupId>
<artifactId>objectify</artifactId>
<version>6.0</version>
</dependency>
<!-- Apache Commons Library -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<!-- Add support for joda money library -->
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-money</artifactId>
<version>0.10.0</version>
</dependency>
<!--Added support for joda time library -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
</dependency>
<!-- end joda time api.-->
<!-- Load scrypt library for password encryption and decryption -->
<dependency>
<groupId>com.lambdaworks</groupId>
<artifactId>scrypt</artifactId>
<version>1.4.0</version>
</dependency>
<!-- Objectify utils to help us with currency -->
<dependency>
<groupId>com.sappenin.objectify</groupId>
<artifactId>objectify-utils</artifactId>
<version>5.1.3</version>
</dependency>
<!-- google guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<!-- Apache poi for excel file processing -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<!-- jackson-dataformat-csv-->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-csv</artifactId>
<version>2.7.0</version>
</dependency>
<!-- jackson data bind library for json -->
<!-- Google cloud storage ends -->
<!-- google cloud storage client -->
<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
<version>0.7</version>
<exclusions>
<exclusion>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.23.0</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>2.0.2-beta</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${appengine.version}</version>
<scope>test</scope>
</dependency>
<!-- Mail Dependencies with MailGun -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.19.1</version>
</dependency>
<!-- End Mail Dependencies with MailGun -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker-gae</artifactId>
<version>2.3.25-incubating</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<!-- Note: core-annotations version x.y.0 is generally compatible with
(identical to) version x.y.1, x.y.2, etc. -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application-->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<stage.enableJarClasses>true</stage.enableJarClasses>
<cloudSdkPath>/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk</cloudSdkPath>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<!-- deploy configuration -->
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>endpoints-framework-maven-plugin</artifactId>
<version>1.0.2</version>
<configuration>
<!-- plugin configuration -->
<hostname>project-id.appspot.com</hostname>
</configuration>
<executions>
<execution>
<goals>
<goal>discoveryDocs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
这是我的 web.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Endpoints web.xml -->
<!-- [START web] -->
<servlet>
<display-name>Remote API Servlet</display-name>
<servlet-name>RemoteApiServlet</servlet-name>
<servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Grader</servlet-name>
<servlet-class>com.softquest.apollo.servlets.Grader</servlet-class>
</servlet>
<servlet>
<servlet-name>SheetHandler</servlet-name>
<servlet-class>com.softquest.apollo.servlets.SheetHandler</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RemoteApiServlet</servlet-name>
<url-pattern>/remote_api</url-pattern>
</servlet-mapping>
<!-- Score Sheet Servlet -->
<!-- Remote Api Servlet -->
<servlet>
<servlet-name>EndpointsServlet</servlet-name>
<servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.softquest.apollo.services.UserServices</param-value>
</init-param>
</servlet>
<!-- Payment Response Servlet -->
<servlet>
<servlet-name>PaymentResponseServlet</servlet-name>
<servlet-class>com.softquest.apollo.servlets.PaymentResponseServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PaymentResponseServlet</servlet-name>
<url-pattern>/PaymentResponse</url-pattern>
</servlet-mapping>
<!-- Payment Response Servlet-->
<servlet-mapping>
<servlet-name>EndpointsServlet</servlet-name>
<url-pattern>/_ah/api/*</url-pattern>
</servlet-mapping>
<!-- Objectify filter registration -->
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Setup ServletContextListener to start up objectify entities on application -->
<servlet>
<servlet-name>BackEndStarter</servlet-name>
<servlet-class>com.softquest.apollo.BackEndStarter</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>BackEndStarter</servlet-name>
<url-pattern>/backend/starter</url-pattern>
</servlet-mapping>
<!-- Migration servlet -->
<servlet>
<servlet-name>MigrationServlet</servlet-name>
<servlet-class>com.softquest.apollo.servlets.MigrationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MigrationServlet</servlet-name>
<url-pattern>/migration/*</url-pattern>
</servlet-mapping>
<!-- Migration Servlet-->
<!-- Migration Handler Servlet -->
<servlet>
<servlet-name>MigrationHandler</servlet-name>
<servlet-class>com.softquest.apollo.servlets.MigrationHandler</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MigrationHandler</servlet-name>
<url-pattern>/migration-handler/*</url-pattern>
</servlet-mapping>
<!-- End of Migration handler Servlet-->
<!-- Setup web.xml to start up context listener -->
<servlet-mapping>
<servlet-name>Grader</servlet-name>
<url-pattern>/Grader</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SheetHandler</servlet-name>
<url-pattern>/SheetHandler</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
我在尝试调用 api 发现文档时遇到此错误,我已将其追溯到 [=16= 的第 72 行的空指针错误]
com.google.api.server.spi.EndpointsServlet 文件
if (!dispatcher.dispatch(method, path, context)) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
response.getWriter().append("Not Found");
}
我猜错误是发布到某些第三方库可能仍在使用任何较旧的云端点 Maven 依赖项或插件。所以我会从我的 pom.xml 中删除所有依赖项并尝试部署。
更新: 我能够修复 API 发现错误,它是由与 Google Guava 库有关的反射错误引起的,而迁移文档已经声明版本 19 可以工作,但它没有t,升级到版本 20 及更高版本为我解决了这个问题,现在我在所有端点上都收到错误 404。当我能够解决这个问题时,我会写一个答案。
我在几个月未更改的端点上遇到同样的问题,日志中也没有任何内容。我认为这可能是一个应用程序引擎问题。
编辑
我解决了我们的问题,尽管您提到您已尝试更新到新的 Cloud Endpoint v2.0 但您仍然遇到问题,结果证明我们的项目遵循从 v1.1 到 v1.1 的迁移步骤v2 修复了问题 https://cloud.google.com/endpoints/docs/frameworks/python/migrating.
文档说 v1.1 将在 8 月 2 日关闭,我猜他们刚刚解决了这个问题
经过一系列的点击和试用方法,我已经成功迁移到 Endpoints V2。
在 Android Studio 上开发的 App Engine 项目具有以下结构-
项目
- 应用程序
- 后端
- build.gradle
我必须更改所有 3 个地方 build.gradle。其中 project 是根项目,app 是 android app,backend 是 App Engine app。所有这些都有自己的 build.gradlew.
让我们一一改变。
/app/build.gradle(在 android 客户端中进行更改)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.+'
// Remove this line
//compile project(path: ':micirclews', configuration: 'android-endpoints')
}
在 android 插件
之后应用端点插件apply plugin: 'com.google.cloud.tools.endpoints-framework-client'
/backend/build.gradle(在 backend/appengine 模块中进行更改)
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
//Remove this
//classpath 'com.google.appengine:gradle-appengine-plugin:1.9.59'
//Add these two lines
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
}
}
删除这个- apply plugin: 'appengine'
加上这两个-
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
dependencies {
//Remove these 3 lines-
//appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.59'
//compile 'com.google.appengine:appengine-endpoints:1.9.59'
//compile 'com.google.appengine:appengine-endpoints-deps:1.9.59'
//Add these 2 lines-
compile 'com.google.endpoints:endpoints-framework:2.0.9'
compile 'javax.inject:javax.inject:1'
.....
}
// delete this whole block, it's configuration for the older plugin
// appengine {
// downloadSdk = true
// appcfg {
// oauth2 = true
// }
// endpoints {
// getClientLibsOnBuild = true
// getDiscoveryDocsOnBuild = true
// }
// }
/build.gradle(在root的build.gradle中进行修改)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
//Add these 2 lines
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
}
}
仔细进行所有更改后,清理项目,重建它并 运行 它。最后在一切正常时部署它。
你可以在这里参考整个过程 - https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin/blob/master/ANDROID_README.md
正如 saiyr 在评论中所述,Google Cloud Endpoints v1.1 已完全弃用并停止提供流量,这就是我遇到错误的原因。 我通过迁移到云端点 v2 解决了这个问题,这个过程就像遵循 migration docs 中的指南一样简单,但这里有一些我在迁移时遇到的问题以及我如何修复它。
Google guava库必须更新到19以上版本,使用19或更低版本可能会导致应用程序在处理请求时抛出反射错误。
如果您有多个服务 classes,则必须在声明
com.google.api.server.spi.EndpointsServlet
Servlet 时将它们作为服务参数添加到 web.xml 文件中。 由于某些原因,仅列出一项服务 class 在云端点 1.0 Api 中为我工作 Api 为我拥有的所有服务 classes 生成了文档和路由,但没有在 [= =11=] Servlet,我认为它与 Objectify 过滤器有关。 See the Docs for more info由于 Google App Engine Java 7 运行时也已弃用,我决定迁移到 Java 8 但不幸的是我用来抽象的库连接到数据存储区 (Objectify) 的过程似乎不适用于 Java 8 运行时,我稍后会研究这个问题,但恢复到 Java 7 运行时对我有用并且应用程序已备份并且运行。
更新:我在迁移到 Java 8 运行时时遇到的问题与 Objectify 无关,我用于加密密码的库 (BCrypt) 是问题所在,它只是在 Google App Engine Java 8 运行时不起作用,我不得不切换到 spring 安全性中的加密库。