appengine endpoint无法检索状态为500的API配置

时间:2014-02-22 07:54:02

标签: java google-app-engine java-7 google-cloud-endpoints

我使用params 0.0.0.0

在eclipse中运行appengine本地开发服务器

当我尝试访问任何方法时,我收到以下错误。如果我尝试访问api explorer,我会得到同样的错误

 http://localhost:8888/_ah/api/explorer

注意:我刚刚将我的应用引擎服务器更新为java 7。

有谁知道如何解决这个问题?

java.io.IOException: Failed to retrieve API configs with status: 500
    at com.google.api.server.spi.tools.devserver.ApiServlet.getApiConfigSources(ApiServlet.java:102)
    at com.google.api.server.spi.tools.devserver.ApiServlet.initConfigsIfNecessary(ApiServlet.java:67)
    at com.google.api.server.spi.tools.devserver.RestApiServlet.service(RestApiServlet.java:117)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
    at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
    at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:487)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

有时错误的第一行是

java.lang.NoClassDefFoundError: com/google/gwt/core/ext/typeinfo/NotFoundException

4 个答案:

答案 0 :(得分:1)

我有同样的问题,我不得不删除我的web.xml并通过模板重做它。更具体地说,这部分:

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>

另外,请确保在API类中定义了API。这是一个示例配置。

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

答案 1 :(得分:0)

我最近遇到了类似的问题,我的问题是使用带有@ApiMethod的公共方法。为了解决这个问题,我重新考虑了我的代码,使这个方法变得私密。但我可以在新方法之前添加这样的一行:

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

答案 2 :(得分:0)

我有类似的例外。 就我而言,我刚添加了新的实体类,忘了用@Entity注释它。 而stacktrace看起来像:

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.

在我向类添加注释后,异常消失了。

答案 3 :(得分:0)

您必须通过将开发服务器设置为侦听外部连接来使您的开发服务器可供网络访问。您可以通过编辑后端项目的build.gradle并设置httpAddress来执行此操作。

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

创建端点时,您还必须将端点根URL更改为指向计算机的IP地址。

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

最佳参考是here