小编Sam*_*den的帖子

com.google.api.config.ServiceConfigSupplier - 无法获取服务的默认配置版本(仅在localhost上)

我正在将Java端点框架(2.0.1)用于Java作为我最后一年项目的一部分,到目前为止它已经相对成功.部署到我的appspot.com域时没有任何问题,但是,我在本地部署时遇到了一些问题.

(以下代码块中对my-project-id的任何引用都是我实际的Google云项目ID的别名)

我有一个带注释的@API类的有效openapi描述符(openapi.json),我使用"gcloud service-management deploy openapi.json"将其部署到云端点.该命令成功返回:

Service Configuration [2017-02-23r0] uploaded for service [api.endpoints.<my-project-id>.cloud.goog]
Run Code Online (Sandbox Code Playgroud)

然后我将返回的config_id映射到app.yaml中正确的endpoints_api_service

endpoints_api_service:
  name: api.endpoints.<my-project-id>.cloud.goog
  config_id: 2017-02-23r0
Run Code Online (Sandbox Code Playgroud)

该服务由gcloud cli工具使用"gcloud service-management list"列出

    NAME                                                           TITLE
    storage-component.googleapis.com                 Google Cloud Storage
    api.endpoints.<my-project-id>.cloud.goog         api.endpoints.<my-project-id>.cloud.goog
    etc...
Run Code Online (Sandbox Code Playgroud)

和"gcloud service-management configs list --service api.endpoints.my-project-id.cloud.goog"

CONFIG_ID        SERVICE_NAME
2017-02-23r0     api.endpoints.<my-project-id>.cloud.goog
... other version configs
Run Code Online (Sandbox Code Playgroud)

并且可以在我的appspot.com域上访问(我可以调用端点并收到正确的响应)

我正在尝试使用java的maven appengine插件(mvn appengine:devserver)在localhost上部署我的项目,但是在jetty启动时我遇到了以下异常:

 WARNING: Failed startup of context com.google.appengine.tools.development.DevAppEngineWebAppContext...

com.google.api.config.ServiceConfigException: Failed to fetch default config version for service 'api.endpoints.<my-project-id>.cloud.goog'. No versions exist!
at com.google.api.config.ServiceConfigSupplier.fetchLatestServiceVersion(ServiceConfigSupplier.java:155)
....
Run Code Online (Sandbox Code Playgroud)

部署然后陷入无休止的循环,尝试启动jetty,并被该错误消息,并重新启动等.任何尝试访问localhost:8080导致"503:服务未找到"错误

我假设我的应用程序的本地部署能够访问使用"gcloud service-management deploy"部署的服务配置,就像appspot.com部署一样,但事实并非如此吗?查看ServiceConfigSupplier.getchLatestServiceVersion()的源代码我收集了serviceManagement.services().configs().list(my-service-name).execute().getServiceConfigs()返回一个空列表,但为什么这只是在当地发生?

额外的信息

我的ENDPOINTS_SERVICE_NAME环境变量与'api.endpoints.my-project-id.cloud.goog'匹配

我注意到几天前com.google.api.config有一个更新(1.0.2),它依赖于旧版本的com.google.api.services.servicemanagement(取决于v1-rev14) -1.22.0,最新版本是v1-rev340-1.22.0)我怀疑这是问题,但我想我会提到它,因为它包含与异常相关的类(ServiceManfigSupplier使用ServiceManagement,它正在抛出例外).他们在寻找服务配置的地方可能存在不一致之处? …

java google-app-engine maven google-cloud-endpoints openapi

7
推荐指数
1
解决办法
1845
查看次数