Java 应用程序引擎将端点定向到以前的类名,现在找不到404

Java 应用程序引擎将端点定向到以前的类名,现在找不到404,java,google-app-engine,Java,Google App Engine,我一直在使用AppEngine作为Android和iOS应用程序的后端。它在http上的本地开发服务器和https上的实际应用引擎上都可以正常工作 然后我注意到,在重命名端点时,我意外地在端点的类名中复制了一个单词:regionregioncendpoint,而不是简单的regioncendpoint。这是一个单线修复 public class RegionRegionIconsEndpoint { @ApiMethod(name = "getRegionIcons", path="re

我一直在使用AppEngine作为Android和iOS应用程序的后端。它在http上的本地开发服务器和https上的实际应用引擎上都可以正常工作

然后我注意到,在重命名端点时,我意外地在端点的类名中复制了一个单词:regionregioncendpoint,而不是简单的regioncendpoint。这是一个单线修复

public class RegionRegionIconsEndpoint {
    @ApiMethod(name = "getRegionIcons", path="regionIcons", httpMethod = HttpMethod.POST)
    public RegionInfoVersion.RegionIcons getRegionIcons(User user, @Named("id") String id)
            throws OAuthRequestException {
        ...
    }
}
变成

public class RegionIconsEndpoint {
    @ApiMethod(name = "getRegionIcons", path="regionIcons", httpMethod = HttpMethod.POST)
    public RegionInfoVersion.RegionIcons getRegionIcons(User user, @Named("id") String id)
            throws OAuthRequestException {
        ...
    }
}
我生成了新的云端点库,并使用本地开发服务器继续开发。一切都好

然而,当我将它部署到真正的应用程序引擎服务时,出现了一个问题。当我的应用程序启动时,会有一系列对其他端点的调用,正如上面所示;这些总是很好用。然后有对该端点的调用。典型的呼叫如下所示:

POST https://my-app.appspot.com/_ah/api/client/v1/regionIcons?id=foo
2014-05-02 21:36:30.551 /_ah/spi/com.example.app.endpoints.RegionIconsEndpoint.getRegionIcons 200 48ms 0kb Google-HTTP-Java-Client/1.16.0-rc (gzip) module=default version=1
70.80.59.221 - - [02/May/2014:18:36:30 -0700] "POST /_ah/spi/com.example.app.endpoints.RegionIconsEndpoint.getRegionIcons HTTP/1.1" 200 149 - "Google-HTTP-Java-Client/1.16.0-rc (gzip)" "my-app.appspot.com" ms=49 cpu_ms=41 cpm_usd=0.000017 app_engine_release=1.9.4 instance=006c1b117c1b2d35341e0f407ae5785a825b65e5
200 OK

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  171
content-type:  application/json; charset=UTF-8
date:  Sat, 03 May 2014 03:12:08 GMT
etag:  "EP5CWx59se1v4KdDnkfEx7cTkis/LUWzmydK3mjH7IeRbEc_n9J6cDQ"
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

{
 "iconsVid": "foo",
 "iconsVersion": 3,
 "kind": "client#resourcesItem",
 "etag": "\"EP5CWx59se1v4KdDnkfEx7cTkis/LUWzmydK3mjH7IeRbEc_n9J6cDQ\""
}
404 Not Found

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  29
content-type:  text/html; charset=UTF-8
date:  Sat, 03 May 2014 03:06:10 GMT
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

Not Found
还提供了授权,大多数情况下会返回预期结果。。。比如说80%。AE日志如下所示:

POST https://my-app.appspot.com/_ah/api/client/v1/regionIcons?id=foo
2014-05-02 21:36:30.551 /_ah/spi/com.example.app.endpoints.RegionIconsEndpoint.getRegionIcons 200 48ms 0kb Google-HTTP-Java-Client/1.16.0-rc (gzip) module=default version=1
70.80.59.221 - - [02/May/2014:18:36:30 -0700] "POST /_ah/spi/com.example.app.endpoints.RegionIconsEndpoint.getRegionIcons HTTP/1.1" 200 149 - "Google-HTTP-Java-Client/1.16.0-rc (gzip)" "my-app.appspot.com" ms=49 cpu_ms=41 cpm_usd=0.000017 app_engine_release=1.9.4 instance=006c1b117c1b2d35341e0f407ae5785a825b65e5
200 OK

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  171
content-type:  application/json; charset=UTF-8
date:  Sat, 03 May 2014 03:12:08 GMT
etag:  "EP5CWx59se1v4KdDnkfEx7cTkis/LUWzmydK3mjH7IeRbEc_n9J6cDQ"
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

{
 "iconsVid": "foo",
 "iconsVersion": 3,
 "kind": "client#resourcesItem",
 "etag": "\"EP5CWx59se1v4KdDnkfEx7cTkis/LUWzmydK3mjH7IeRbEc_n9J6cDQ\""
}
404 Not Found

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  29
content-type:  text/html; charset=UTF-8
date:  Sat, 03 May 2014 03:06:10 GMT
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

Not Found
其余时间,我收到404 Not Found响应,AE日志有以下内容:

2014-05-02 21:36:30.852 /_ah/spi/BackendService.logMessages 204 16ms 0kb module=default version=1
10.1.0.41 - - [02/May/2014:18:36:30 -0700] "POST /_ah/spi/BackendService.logMessages HTTP/1.1" 204 0 - - "my-app.appspot.com" ms=16 cpu_ms=0 app_engine_release=1.9.4 instance=006c1b117c1b2d35341e0f407ae5785a825b65e5
E 2014-05-02 21:36:30.851
Request URL: https://my-app.appspot.com/_ah/api/client/v1/regionIcons?id=foo
Method: client.getRegionIcons
Error Code: 404
Reason: notFound
Message: service 'com.example.app.endpoints.RegionRegionIconsEndpoint' not found

2014-05-02 21:36:30.802 /_ah/spi/com.example.app.endpoints.RegionRegionIconsEndpoint.getRegionIcons 404 16ms 0kb Google-HTTP-Java-Client/1.16.0-rc (gzip) module=default version=1
70.80.59.221 - - [02/May/2014:18:36:30 -0700] "POST /_ah/spi/com.example.app.endpoints.RegionRegionIconsEndpoint.getRegionIcons HTTP/1.1" 404 166 - "Google-HTTP-Java-Client/1.16.0-rc (gzip)" "my-app.appspot.com" ms=16 cpu_ms=0 cpm_usd=0.000019 app_engine_release=1.9.4 instance=006c1b117c1b2d35341e0f407ae5785a825b65e5
您可以在消息行中看到,有时,AE仍在尝试使用旧类名和重复单词处理调用!我已经搜索了我的整个代码库和生成的文件,但我在任何地方都找不到字符串RegionRegion。我已经检查了web.xml文件十几次,它只有新的RegionSecondpoint类名

public class RegionRegionIconsEndpoint {
    @ApiMethod(name = "getRegionIconsOld", path="regionIconsOld", httpMethod = HttpMethod.POST)
    public RegionInfoVersion.RegionIcons getRegionIcons(User user, @Named("id") String id)
            throws OAuthRequestException {
        ...
    }
}
不知谷歌的服务器是否在保留旧信息,我将我的应用程序的新版本部署为2-dot-my-app.appspot.com。该行为保持完全相同,除了此版本上404失败的请求没有AE日志消息。成功的请求日志与以前一样

我的Android和iPad应用程序都经历过这种情况。此外,我还设法在my-app.appspot.com上通过网络和谷歌的API浏览器复制了它。在最后一种情况下,成功的请求显示:

200 OK

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  171
content-type:  application/json; charset=UTF-8
date:  Sat, 03 May 2014 03:07:05 GMT
etag:  "G170GGjYGsLnxTffzUEJmTttHzU/LUWzmydK3mjH7IeRbEc_n9J6cDQ"
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

{
 "iconsVid": "foo",
 "iconsVersion": 3,
 "kind": "client#resourcesItem",
 "etag": "\"G170GGjYGsLnxTffzUEJmTttHzU/LUWzmydK3mjH7IeRbEc_n9J6cDQ\""
}
404 Not Found

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  169
content-type:  application/json; charset=UTF-8
date:  Sat, 03 May 2014 03:08:34 GMT
expires:  Sat, 03 May 2014 03:08:34 GMT
server:  GSE

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "service 'com.example.app.endpoints.RegionRegionIconsEndpoint' not found"
   }
  ],
  "code": 404,
  "message": "service 'com.example.app.endpoints.RegionRegionIconsEndpoint' not found"
 }
}
一个失败的请求显示:

200 OK

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  171
content-type:  application/json; charset=UTF-8
date:  Sat, 03 May 2014 03:07:05 GMT
etag:  "G170GGjYGsLnxTffzUEJmTttHzU/LUWzmydK3mjH7IeRbEc_n9J6cDQ"
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

{
 "iconsVid": "foo",
 "iconsVersion": 3,
 "kind": "client#resourcesItem",
 "etag": "\"G170GGjYGsLnxTffzUEJmTttHzU/LUWzmydK3mjH7IeRbEc_n9J6cDQ\""
}
404 Not Found

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  169
content-type:  application/json; charset=UTF-8
date:  Sat, 03 May 2014 03:08:34 GMT
expires:  Sat, 03 May 2014 03:08:34 GMT
server:  GSE

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "service 'com.example.app.endpoints.RegionRegionIconsEndpoint' not found"
   }
  ],
  "code": 404,
  "message": "service 'com.example.app.endpoints.RegionRegionIconsEndpoint' not found"
 }
}
再次清楚地显示对旧类名的访问。当尝试对我部署的2-dot-my-app.appspot.com的v2版本执行相同操作时,情况有所不同。成功请求的结尾如下所示:

POST https://my-app.appspot.com/_ah/api/client/v1/regionIcons?id=foo
2014-05-02 21:36:30.551 /_ah/spi/com.example.app.endpoints.RegionIconsEndpoint.getRegionIcons 200 48ms 0kb Google-HTTP-Java-Client/1.16.0-rc (gzip) module=default version=1
70.80.59.221 - - [02/May/2014:18:36:30 -0700] "POST /_ah/spi/com.example.app.endpoints.RegionIconsEndpoint.getRegionIcons HTTP/1.1" 200 149 - "Google-HTTP-Java-Client/1.16.0-rc (gzip)" "my-app.appspot.com" ms=49 cpu_ms=41 cpm_usd=0.000017 app_engine_release=1.9.4 instance=006c1b117c1b2d35341e0f407ae5785a825b65e5
200 OK

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  171
content-type:  application/json; charset=UTF-8
date:  Sat, 03 May 2014 03:12:08 GMT
etag:  "EP5CWx59se1v4KdDnkfEx7cTkis/LUWzmydK3mjH7IeRbEc_n9J6cDQ"
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

{
 "iconsVid": "foo",
 "iconsVersion": 3,
 "kind": "client#resourcesItem",
 "etag": "\"EP5CWx59se1v4KdDnkfEx7cTkis/LUWzmydK3mjH7IeRbEc_n9J6cDQ\""
}
404 Not Found

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  29
content-type:  text/html; charset=UTF-8
date:  Sat, 03 May 2014 03:06:10 GMT
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

Not Found
失败的请求的结尾如下所示:

POST https://my-app.appspot.com/_ah/api/client/v1/regionIcons?id=foo
2014-05-02 21:36:30.551 /_ah/spi/com.example.app.endpoints.RegionIconsEndpoint.getRegionIcons 200 48ms 0kb Google-HTTP-Java-Client/1.16.0-rc (gzip) module=default version=1
70.80.59.221 - - [02/May/2014:18:36:30 -0700] "POST /_ah/spi/com.example.app.endpoints.RegionIconsEndpoint.getRegionIcons HTTP/1.1" 200 149 - "Google-HTTP-Java-Client/1.16.0-rc (gzip)" "my-app.appspot.com" ms=49 cpu_ms=41 cpm_usd=0.000017 app_engine_release=1.9.4 instance=006c1b117c1b2d35341e0f407ae5785a825b65e5
200 OK

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  171
content-type:  application/json; charset=UTF-8
date:  Sat, 03 May 2014 03:12:08 GMT
etag:  "EP5CWx59se1v4KdDnkfEx7cTkis/LUWzmydK3mjH7IeRbEc_n9J6cDQ"
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

{
 "iconsVid": "foo",
 "iconsVersion": 3,
 "kind": "client#resourcesItem",
 "etag": "\"EP5CWx59se1v4KdDnkfEx7cTkis/LUWzmydK3mjH7IeRbEc_n9J6cDQ\""
}
404 Not Found

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  29
content-type:  text/html; charset=UTF-8
date:  Sat, 03 May 2014 03:06:10 GMT
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

Not Found
我不知道还能尝试什么。对我来说,它看起来像是应用程序引擎中的一个bug

所以。。。你知道这里发生了什么,以及如何修复或解决它吗

2014-05-04:我试着将POST的方法改为:完全相同的行为。我尝试将路径从regionIcons更改为regionIconsFoo:完全相同的行为。我尝试将@API版本从v1更改为v2:完全相同的行为

最后,我尝试使用重复的单词将类名改回上一个:失败次数可能会减少5%,而不是20%,但如果请求尝试访问现在不存在的类名而不使用重复的单词,失败次数仍然会出现


恢复正确的名称将恢复最初描述的行为,并保持最初的失败率。

我一直在努力解决类似的问题。检查appengine.com项目站点上的日志。您应该看到关于更新的日志,如果它有关于错误的其他信息,请检查它。 有时AE在本地机器上工作得很好,但部署过程中暴露出一些错误

编辑:

一,。将类重新命名为旧的double name,将其上载到AE,并检查所有请求是否都正常工作,如果是,请再次重命名该类。如果它是一个引擎错误,它应该修复它


二,。创建尽可能简单的api,并用项目替换它。将其更新为AE,并使用api资源管理器检查是否一切正常,没有主项目中的方法。如果可以,请再次将测试项目与真实项目交换并上传到AE。

这不是答案,因为它没有解决问题的原因,但这是我的解决方案

我将工人阶级复制回旧的类名

public class RegionRegionIconsEndpoint {
    @ApiMethod(name = "getRegionIconsOld", path="regionIconsOld", httpMethod = HttpMethod.POST)
    public RegionInfoVersion.RegionIcons getRegionIcons(User user, @Named("id") String id)
            throws OAuthRequestException {
        ...
    }
}
现在在日志中,尽管我只调用了getRegionIcons,但我看到有迹象表明,这两个类都是用处理大约20%请求的旧版本调用的。这是一个黑客,我不喜欢它,但它的工作和客户都很满意


如果你不能打败他们,就加入他们。

这就是问题所在,管理日志显示原始版本=1部署和新版本=2部署的API配置都已成功更新。Brian,打开.appspot.com//u ah/API/explorer,检查所有API的名称和方法是否正确。是,它们的外观和行为都与预期的一样,除了这一个,它在引用和旧类名时失败了20%。当然,这是唯一一个更改了类名的端点。我看到了您的编辑,就在我来这里向报告添加更新时。对于我的下一个技巧,我将包括旧的和新的类名,看看会发生什么。几周后,我上传了一个没有旧类的新版本。没问题。看来阿彭金一定有 e记住以前的端点->类名关联,并在新旧端点之间半随机选取。经过足够的时间,以前的联系已经完全忘记了,问题也消失了。