ServiceConfigException When Api Management is Added

拟墨画扇 提交于 2019-12-11 17:13:22

问题


I started to get error, ServiceConfigException, after I've tried to add Api Management to my project just as explained here.

Commenting out ServiceManagementConfigFilter lines from web.xml lines as told here solves my problem but leaves my project without API support.

I'd love to get some help. Thanks in advance.

--------------------------------------------------------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building PROJECT-NAME 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> appengine-maven-plugin:1.3.2:run (default-cli) > package @ PROJECT-NAME >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ PROJECT-NAME ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\NAME\Repos\PROJECT-FOLDER\Backend\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ PROJECT-NAME ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ PROJECT-NAME ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ PROJECT-NAME ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ PROJECT-NAME ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.6:war (default-war) @ PROJECT-NAME ---
[INFO] Packaging webapp
[INFO] Assembling webapp [PROJECT-NAME] in [C:\Users\NAME\Repos\PROJECT-FOLDER\Backend\target\PROJECT-NAME-1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp webResources [C:\Users\NAME\Repos\PROJECT-FOLDER\Backend/src/main/webapp/WEB-INF] to [C:\Users\NAME\Repos\PROJECT-FOLDER\Backend\target\PROJECT-NAME-1.0-SNAPSHOT]
[INFO] Copying webapp resources [C:\Users\NAME\Repos\PROJECT-FOLDER\Backend\src\main\webapp]
[INFO] Webapp assembled in [2435 msecs]
[INFO] Building war: C:\Users\NAME\Repos\PROJECT-FOLDER\Backend\target\PROJECT-NAME-1.0-SNAPSHOT.war
[INFO]
[INFO] <<< appengine-maven-plugin:1.3.2:run (default-cli) < package @ PROJECT-NAME <<<
[INFO]
[INFO] --- appengine-maven-plugin:1.3.2:run (default-cli) @ PROJECT-NAME ---
May 03, 2018 1:15:30 AM com.google.cloud.tools.appengine.cloudsdk.CloudSdkAppEngineDevServer1 run
INFO: Setting appengine-web.xml configured environment variables: ENDPOINTS_SERVICE_VERSION=2017-04-20r1,ENDPOINTS_SERVICE_NAME=PROJECT-ID.appspot.com
May 03, 2018 1:15:30 AM com.google.cloud.tools.appengine.cloudsdk.CloudSdk logCommand
INFO: submitting command: C:\Program Files\Java\jdk1.8.0_131\jre\bin\java.exe -Duse_jetty9_runtime=true -D--enable_all_permissions=true -Dappengine.sdk.root=C:\Users\NAME\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java -cp C:\Users\NAME\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java\lib\appengine-tools-api.jar com.google.appengine.tools.development.DevAppServerMain --allow_remote_shutdown --disable_update_check --no_java_agent C:\Users\NAME\Repos\PROJECT-FOLDER\Backend\target\PROJECT-NAME-1.0-SNAPSHOT
[INFO] GCLOUD: May 03, 2018 1:15:30 AM java.util.prefs.WindowsPreferences <init>
[INFO] GCLOUD: WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[INFO] GCLOUD: May 03, 2018 1:15:30 AM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
[INFO] GCLOUD: INFO: Overwriting system property key 'java.util.logging.config.file', value 'C:\Users\NAME\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java\config\sdk\logging.properties' with value 'WEB-INF/logging.properties' from 'C:\Users\NAME\Repos\PROJECT-FOLDER\Backend\target\PROJECT-NAME-1.0-SNAPSHOT\WEB-INF\appengine-web.xml'
[INFO] GCLOUD: 2018-05-03 01:15:30.671:INFO::main: Logging initialized @299ms
[INFO] GCLOUD: 2018-05-03 01:15:30.937:INFO:oejs.Server:main: jetty-9.3.18.v20170406
[INFO] GCLOUD: 2018-05-03 01:15:33.340:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=2120ms
[INFO] GCLOUD: May 02, 2018 10:15:33 PM com.google.appengine.tools.development.ApiProxyLocalImpl log
[INFO] GCLOUD: INFO: javax.servlet.ServletContext log: OfyHelper: Init
[INFO] GCLOUD: May 02, 2018 10:15:46 PM com.google.api.control.Client start
[INFO] GCLOUD: INFO: starting com.google.api.control.Client@1c9f0a20
[INFO] GCLOUD: May 02, 2018 10:15:46 PM com.google.api.control.Client initializeFlushing
[INFO] GCLOUD: INFO: creating a scheduler to control flushing
[INFO] GCLOUD: May 02, 2018 10:15:46 PM com.google.api.control.Client initializeFlushing
[INFO] GCLOUD: INFO: scheduling the initial check, report, and quota
[INFO] GCLOUD: 2018-05-03 01:15:46.613:WARN:oejw.WebAppContext:main: Failed startup of context c.g.a.t.d.j.DevAppEngineWebAppContext@5e8f9e2d{/,file:///C:/Users/NAME/Repos/PROJECT-FOLDER/Backend/target/PROJECT-NAME-1.0-SNAPSHOT/,UNAVAILABLE}{C:\Users\NAME\Repos\PROJECT-FOLDER\Backend\target\PROJECT-NAME-1.0-SNAPSHOT}
[INFO] GCLOUD: com.google.api.config.ServiceConfigException: Failed to fetch service config (status code 404)
[INFO] GCLOUD:     at com.google.api.config.ServiceConfigSupplier.fetch(ServiceConfigSupplier.java:143)
[INFO] GCLOUD:     at com.google.api.config.ServiceConfigSupplier.get(ServiceConfigSupplier.java:111)
[INFO] GCLOUD:     at com.google.api.config.ServiceConfigSupplier.get(ServiceConfigSupplier.java:49)
[INFO] GCLOUD:     at com.google.common.base.Suppliers$ExpiringMemoizingSupplier.get(Suppliers.java:227)
[INFO] GCLOUD:     at com.google.api.config.ServiceConfigFetcher.fetch(ServiceConfigFetcher.java:41)
[INFO] GCLOUD:     at com.google.api.control.ServiceManagementConfigFilter$1.load(ServiceManagementConfigFilter.java:33)
[INFO] GCLOUD:     at com.google.api.control.ConfigFilter.init(ConfigFilter.java:87)
[INFO] GCLOUD:     at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139)
[INFO] GCLOUD:     at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:873)
[INFO] GCLOUD:     at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
[INFO] GCLOUD:     at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1406)
[INFO] GCLOUD:     at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1368)
[INFO] GCLOUD:     at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
[INFO] GCLOUD:     at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
[INFO] GCLOUD:     at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:522)
[INFO] GCLOUD:     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
[INFO] GCLOUD:     at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
[INFO] GCLOUD:     at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
[INFO] GCLOUD:     at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
[INFO] GCLOUD:     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
[INFO] GCLOUD:     at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
[INFO] GCLOUD:     at org.eclipse.jetty.server.Server.start(Server.java:422)
[INFO] GCLOUD:     at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
[INFO] GCLOUD:     at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
[INFO] GCLOUD:     at org.eclipse.jetty.server.Server.doStart(Server.java:389)
[INFO] GCLOUD:     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
[INFO] GCLOUD:     at com.google.appengine.tools.development.jetty9.JettyContainerService.startContainer(JettyContainerService.java:346)
[INFO] GCLOUD:     at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:284)
[INFO] GCLOUD:     at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26)
[INFO] GCLOUD:     at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:87)
[INFO] GCLOUD:     at com.google.appengine.tools.development.Modules.startup(Modules.java:105)
[INFO] GCLOUD:     at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:274)
[INFO] GCLOUD:     at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
[INFO] GCLOUD:     at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:219)
[INFO] GCLOUD:     at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:217)
[INFO] GCLOUD:     at java.security.AccessController.doPrivileged(Native Method)
[INFO] GCLOUD:     at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:217)
[INFO] GCLOUD:     at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:368)
[INFO] GCLOUD:     at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:45)
[INFO] GCLOUD:     at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:223)
[INFO] GCLOUD:     at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:214)
[INFO] GCLOUD: 2018-05-03 01:15:46.625:INFO:oejs.AbstractConnector:main: Started NetworkTrafficSelectChannelConnector@2cf23c81{HTTP/1.1,[http/1.1]}{localhost:8080}
[INFO] GCLOUD: 2018-05-03 01:15:46.626:INFO:oejs.Server:main: Started @16242ms
[INFO] GCLOUD: May 02, 2018 10:15:46 PM com.google.appengine.tools.development.AbstractModule startup
[INFO] GCLOUD: INFO: Module instance default is running at http://localhost:8080/
[INFO] GCLOUD: May 02, 2018 10:15:46 PM com.google.appengine.tools.development.AbstractModule startup
[INFO] GCLOUD: INFO: The admin console is running at http://localhost:8080/_ah/admin
[INFO] GCLOUD: May 03, 2018 1:15:46 AM com.google.appengine.tools.development.DevAppServerImpl doStart
[INFO] GCLOUD: INFO: Dev App Server is now running

回答1:


Removing the ENDPOINTS_SERVICE_VERSION from appengine-web.xml magically solved the problem. Though I don't know how it is related.

Edit: Commenting out these lines solves the problem but disables api key support.

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

Edit: Let's add a little bit of depth why the problem occurred.

When openapi.json file deployed by using gcloud endpoints services deploy openapi.json command, it echoes a service configuration id like 2017-02-13r0. You should be using that in appengine-web.xml as the value of environment variable ENDPOINTS_SERVICE_VERSION.

Since, copying and pushing the new service name is found fairly clunky flow (and it really was), on the later stages of cloudendpoints, they changed it to, if not specified any, the latest version of ENDPOINTS_SERVICE_VERSION will be used.



来源:https://stackoverflow.com/questions/50144500/serviceconfigexception-when-api-management-is-added

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!