我有一个Android应用程序,我想添加一个服务后端与GCM交谈。我已经按照本教程:https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/GcmEndpoints创建了一个带有Google Cloud Messaging模块的App Engine后端到android studio中的android项目。但是,当我运行应用引擎后端项目时,我收到此错误:
java.lang.ClassNotFoundException: com.google.api.server.spi.SystemServiceServlet.
完整堆栈如下:
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:216)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.mortbay.util.Loader.loadClass(Loader.java:91)
at org.mortbay.util.Loader.loadClass(Loader.java:71)
at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:73)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:242)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:254)
at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:305)
at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26)
at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:79)
at com.google.appengine.tools.development.Modules.startup(Modules.java:97)
at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:255)
at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:213)
at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:211)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:211)
at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:277)
at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:219)
at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:210)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
以下是web.xml文件的内容:
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.example.mymodule.backend.RegistrationEndpoint, com.example.mymodule.backend.MessagingEndpoint</param-value>
</init-param>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
这是传递给Java引擎的命令行。
"C:\Program Files\Java\jdk1.7.0_80\bin\java" -javaagent:C:\Users\xx\.gradle\appengine-sdk\appengine-java-sdk-1.9.4\lib\agent\appengine-agent.jar -Xbootclasspath/p:C:\Users\xx\.gradle\appengine-sdk\appengine-java-sdk-1.9.4\lib\override\appengine-dev-jdk-overrides.jar -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\Android\android-studio\bin" -Dfile.encoding=windows-1252 -classpath "C:\Users\xx\.gradle\appengine-sdk\appengine-java-sdk-1.9.4\lib\appengine-tools-api.jar;C:\Program Files (x86)\Android\android-studio\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.google.appengine.tools.development.DevAppServerMain --address=127.0.0.1 --port=8080 C:\Users\xx\Documents\Android\GroceryList\backend\src\main\webapp
非常感谢有关如何解决此错误的任何建议。
答案 0 :(得分:0)
我通过将App Engine项目的“战争路径”设置为\ build \ explosion-app来解决了这个问题。这应该由Android Studio自动生成。出于某种原因,当我添加新的应用引擎模块时,未生成新配置,因此我必须手动创建应用引擎的配置和设置。