appengine endpoint Failed to retrieve API configs with status: 500

旧时模样 提交于 2019-11-28 13:26:33

I had the same issue and I had to delete my web.xml and redo it via a template. More specifically this section:

servlet-name>SystemServiceServlet</servlet-name>
    <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
    <init-param>
        <param-name>services</param-name>
        <param-value>YOUR-API-CLASS</param-value>
    </init-param>
</servlet>

Also, make sure that you have your API defined in your API class. Here is just a sample configuration.

@Api(name = "apiname", version = "1.00",
    scopes = (Constants.EMAIL_SCOPE) , clientIds = {
    Constants.WEB_CLIENT_ID,
    Constants.API_EXPLORER_CLIENT_ID },
    description = "API Description")

I recently encountered a similar problem, and mine was caused by having public methods with an @ApiMethod. To fix this I re-factored my code to make the methode private. But I could have added a line like this before the new method:

@ApiMethod(name = "yourNewPublicMethod", path = "profile", httpMethod = HttpMethod.POST)

I got similar exception. In my case, I just added new entity class and forgot to annotate it with @Entity. And stacktrace looked like:

java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at com.google.api.server.spi.ServletInitializationParameters.getClassForName(ServletInitializationParameters.java:82)
...
Caused by: java.lang.IllegalArgumentException: class com.myapp.entity.Stat must be annotated with either @Entity or @Subclass
at com.googlecode.objectify.impl.Registrar.register(Registrar.java:81)
at com.googlecode.objectify.ObjectifyFactory.register(ObjectifyFactory.java:185)
at com.googlecode.objectify.ObjectifyService.register(ObjectifyService.java:64)
...
Jun 18, 2016 7:13:39 PM com.google.apphosting.utils.jetty.JettyLogger warn
 WARNING: /_ah/api/discovery/v1/apis/userapi/v1/rest: java.io.IOException:      
Failed to retrieve API configs with status: 500
Jun 18, 2016 7:13:39 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: /_ah/spi/BackendService.getApiConfigs
java.lang.NullPointerException
at com.google.api.server.spi.SystemServiceServlet.

After I added annotation to class, exception is gone.

You must make your development server accessible to the network by setting it to listen to external connections. You can do this by editing the build.gradle for the backend project and setting the httpAddress.

appengine {
  ....
  httpAddress = "0.0.0.0"
  ....
}

You must also change the endpoint root url to point to your computer's ip address when creating the endpoint .

Registration.Builder builder = new Registration.Builder(AndroidHttp.newCompatibleTransport(),
        new AndroidJsonFactory(), null)
        .setRootUrl("http://<my-computer-address>:8080/_ah/api/")
        ....

best reference is here

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