如何获取google app引擎的开发servlet以查找RestApiServlet?

时间:2017-09-09 03:17:48

标签: java android google-app-engine servlets

我有一个旧的Android项目,我在其上使用了Google应用引擎后端。 在重新启动项目后,我必须在https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating

之后迁移到应用引擎的V2.0

我不得不做了很多改变,偶然发现了几个问题,其中一些是通过遵循这里的建议来解决的: http://android.serverbox.ch/?p=1891&cpage=1#comment-146146

我能够运行开发服务器并使用Web打开端点页面。 但是,当我运行我的应用程序并连接到端点以将一些数据写入文件时,我收到以下错误:

  

无法初始化类com.google.api.server.spi.tools.devserver.RestApiServlet

由以下原因引起:

java.lang.NoClassDefFoundError:无法初始化com.google类。 api.server.spi.tools.devserver.RestApiServlet                                                                          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)                                                                          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)                                                                          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)                                                                          at java.lang.reflect.Constructor.newInstance(Constructor.java:423)                                                                          在java.lang.Class.newInstance(Class.java:442)                                                                          在org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)                                                                          在org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)                                                                          在org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)                                                                          在org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)                                                                          在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1166)                                                                          在com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)                                                                          在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)                                                                          在com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:134)                                                                          在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)                                                                          在com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)                                                                          在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)                                                                          在com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)                                                                          在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)                                                                          在com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)                                                                          在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)                                                                          在com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)                                                                          在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)                                                                          在com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)                                                                          在com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)                                                                          在com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)                                                                          在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)                                                                          在org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)                                                                          在org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)                                                                          在org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)                                                                          在org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)                                                                          在org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)                                                                          在com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:95)                                                                          在org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)                                                                          在com.google.appengine.tools.development.JettyContainerService $ ApiProxyHandler.handle(JettyContainerService.java:508)                                                                          在org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)                                                                          在org.mortbay.jetty.Server.handle(Server.java:326)                                                                          在org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)   09-08 19:42:54.284 14926-15331 / com.androdev.flightlog E / FlightLog:at org.mortbay.jetty.HttpConnection $ RequestHandler.content(HttpConnection.java:938)                                                                          在org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)                                                                          在org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)                                                                          在org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)                                                                          在org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)                                                                          在org.mortbay.thread.QueuedThreadPool $ PoolThread.run(QueuedThreadPool.java:582)

似乎某些库(jar)尚未加载或者jetty服务器没有运行正确的代码。 我发现它正在寻找的类(RestApiServlet)出现在gradle缓存中的jar中:appengine-local-endpoints-1.9.55.jar

我怎么能加载?或者我需要做些什么才能重新配置服务器?

PS:它可能不相关,但这都是在Android Studio下完成的。因此,Android Studio应该有助于设置,但我的经验是,它通常会促使您关注更新并使您处于破碎状态。这是一种情况。我用' android-studio'标记了这个问题。但没有提到这一切都在Android Studio下。

1 个答案:

答案 0 :(得分:1)

事实证明,迁移的Google页面已更新。再次阅读说明并确保我的所有gradle文件都遵循更新的说明确实解决了问题。后端gradle文件和web.xml文件中的一些更改似乎是问题所在。