com.google.api.config.ServiceConfigSupplier-无法获取服务的默认配置版本(仅在本地主机上) [英] com.google.api.config.ServiceConfigSupplier - Failed to fetch default config version for service (only on localhost)

查看:140
本文介绍了com.google.api.config.ServiceConfigSupplier-无法获取服务的默认配置版本(仅在本地主机上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

Service Configuration [2017-02-23r0] uploaded for service [api.endpoints.<my-project-id>.cloud.goog]

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

endpoints_api_service:
  name: api.endpoints.<my-project-id>.cloud.goog
  config_id: 2017-02-23r0

gcloud cli工具使用"gcloud服务管理列表"列出了该服务

    NAME                                                           TITLE
    storage-component.googleapis.com                 Google Cloud Storage
    api.endpoints.<my-project-id>.cloud.goog         api.endpoints.<my-project-id>.cloud.goog
    etc...

和"gcloud服务管理配置列表--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

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

我正在尝试使用Java的maven appengine插件(mvn appengine:devserver)在本地主机上部署我的项目,但是在码头启动时,我遇到以下异常:

 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)
....

然后,部署陷入了一个无休止的循环,试图启动码头,并被该错误消息击中,然后重新启动等.任何访问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) 我怀疑这是问题所在,但我想我会提一提,因为它包含与异常相关的类(ServiceConfigment由ServiceConfigSupplier使用,引发了异常).也许他们在哪里寻找服务配置不一致?

我很沮丧,这有点困扰我.我不喜欢删除Endpoints,因为我开始喜欢它,但是我们也不能真的失去对devserver的使用.我希望有人能对此问题有所启发.

解决方案

这不是修复程序,但我能够通过使用

I'm using Cloud Endpoints Frameworks (2.0.1) for Java as part of my final year project and have been relatively successful with it so far. I don't have any problems when deploying to my appspot.com domain, however, I am running into some problems when deploying locally.

(Any references to my-project-id in the following code blocks are aliases for my actual google cloud project id)

I have a valid openapi descriptor (openapi.json) of an annotated @API class which I am deploying to cloud endpoints using "gcloud service-management deploy openapi.json". The command returns successfully:

Service Configuration [2017-02-23r0] uploaded for service [api.endpoints.<my-project-id>.cloud.goog]

I then map the returned config_id to the correct endpoints_api_service in my app.yaml

endpoints_api_service:
  name: api.endpoints.<my-project-id>.cloud.goog
  config_id: 2017-02-23r0

This service is listed by the gcloud cli tool using "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...

and "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

and is accessible on my appspot.com domain (I can call the endpoint and receive the correct response)

I am trying to deploy my project on localhost using the maven appengine plugin for java (mvn appengine:devserver), but upon jetty startup I'm hit with the following Exception:

 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)
....

The deployment then gets stuck in an endless cycle of trying to start jetty, and being hit with that error message, and restarting etc. Any attempts to access localhost:8080 result in a "503: Service not found" error

I assumed that the local deployment of my app would be able to access the service config that was deployed using "gcloud service-management deploy", in the same way that the appspot.com deployment can, but is this not the case? Looking at the source for ServiceConfigSupplier.getchLatestServiceVersion() I gather that serviceManagement.services().configs().list(my-service-name).execute().getServiceConfigs() is returning an empty list, but why is this only occurring locally?

Extra Information

my ENDPOINTS_SERVICE_NAME environment variable matches 'api.endpoints.my-project-id.cloud.goog'

I noticed that there was an update (1.0.2) to com.google.api.config a few days ago, and it has a dependency on an older version of com.google.api.services.servicemanagement (dependent on v1-rev14-1.22.0 with the newest version being v1-rev340-1.22.0) I doubt this is the problem, but I thought I would mention it, as it contains classes relevant to the exception (ServiceManagement is used by ServiceConfigSupplier, which is throwing the exception). Perhaps there is an inconsistency in where they are looking for the service configs?

I'm quite stumped tbh, it's a bit over my head. I would dislike having to remove Endpoints, as I'm starting to like it, but we also can't really lose usage of our devserver either. I hope someone can shed a little bit of light on this issue.

解决方案

It's not a fix but I was able to work around the problem by using the advice in https://stackoverflow.com/a/41493548/1410035.

Namely, commenting out the ServiceManagementConfigFilter:

b) Comment out the ServiceManagementConfigFilter from web.xml , ie,

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

Note that you have to comment out the filter and the filter-mapping and they aren't right next to each other in the file.

I found that I didn't need to remove the scaling block as mentioned in point 'a' in the linked answer.

这篇关于com.google.api.config.ServiceConfigSupplier-无法获取服务的默认配置版本(仅在本地主机上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆