迁移到Google Endpoints V2后的404

时间:2018-03-06 14:53:32

标签: google-app-engine google-cloud-endpoints-v2

我们在应用程序中成功使用了Endpoints V1几年。现在,当尝试迁移到Endpoints V2时,它突然停止,只是简单地找不到EndpointsServlet而只是总是返回404.

  • 我可以使用https://apis-explorer.appspot.com/apis-explorer/
  • 浏览api
  • 我可以看到请求来自后端和我正在使用的一个过滤器
  • 但它永远不会找到/到达EndpointsServlet或任何端点
  • 奇怪的是它在localhost devserver中工作??

这仍然是一个已知问题(对于某些应用)或者我该如何解决此问题?

404响应如下:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "\u003chtml\u003e\u003chead\u003e\n\u003cmeta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"\u003e\n\u003ctitle\u003e404 Not Found\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody text=#000000 bgcolor=#ffffff\u003e\n\u003ch1\u003eError: Not Found\u003c/h1\u003e\n\u003c/body\u003e\u003c/html\u003e\n"
   }
  ],
  "code": 404,
  "message": "\u003chtml\u003e\u003chead\u003e\n\u003cmeta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"\u003e\n\u003ctitle\u003e404 Not Found\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody text=#000000 bgcolor=#ffffff\u003e\n\u003ch1\u003eError: Not Found\u003c/h1\u003e\n\u003c/body\u003e\u003c/html\u003e\n"
 }
}

3 个答案:

答案 0 :(得分:1)

解决方法是在使用Endpoints V2部署应用时使用全新的未使用版本名称,而不是:

https://test-dot-[app_id].appspot.com (this used previously Endpoints V1)

使用全新的版本名称,例如

https://test-new-dot-[app_id].appspot.com

如上所述:https://cloud.google.com/endpoints/docs/known-issues

  

" ...您当前必须部署到新的App Engine应用程序版本。重用旧的应用版本可能会与旧的端点部署冲突..."

答案 1 :(得分:0)

当我仍然将SystemServiceServlet配置为使用旧的url模式时,我遇到了这个问题。

正确:

 <servlet-mapping>
    <servlet-name>SystemServiceServlet</servlet-name>
    <url-pattern>/_ah/api/*</url-pattern>
 </servlet-mapping>

不正确:

 <servlet-mapping>
    <servlet-name>SystemServiceServlet</servlet-name>
    <url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>

V2的servlet类也更改为:com.google.api.server.spi.EndpointsServlet

答案 2 :(得分:0)

确定

  1. 您在web.xml中有此部分(无论您是否在POM.XML中都有它!)
 <!-- Wrap the backend with Endpoints Frameworks v2. --> 
    <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.example.echo.Echo,com.example.echo.Foo</param-value>
        </init-param>
    </servlet>
<!--     Route API method requests to the backend. -->
    <servlet-mapping>
        <servlet-name>EndpointsServlet</servlet-name>
        <url-pattern>/_ah/api/*</url-pattern>
    </servlet-mapping>
  1. 您在web.xml,pom.xml,appengine-web.xml中正确且一致的{ProjectId}。如果使用gcloud shell,请检查当前的活动配置及其项目。

  2. 为了安全起见,请在从旧框架V1迁移到V2的同时在新版本上部署您的应用。

相关问题